From zero-kelvin at gmx.de Thu Sep 19 21:41:55 2013 From: zero-kelvin at gmx.de (dexter) Date: Thu, 19 Sep 2013 23:41:55 +0200 Subject: UPDATE -- Osmocom Berlin User Group meeting -- NEXT MEETING In-Reply-To: <20130605121428.GA10030@nataraja.gnumonks.org> References: <502d01a9.mirider@mirider.augusta.de> <20120818115942.GV29525@prithivi.gnumonks.org> <51AF0097.10402@gmx.de> <20130605121428.GA10030@nataraja.gnumonks.org> Message-ID: <523B6FA3.1080701@gmx.de> Hi All. It's time Again! This is the announcement for the next Osmocom Berlin meeting. Sep 25, 8pm @ CCC Berlin, Marienstr. 11, 10117 Berlin There is no formal presentation scheduled for this meeting. If you are interested to show up, feel free to do so. There is no registration required. The meeting is free as in "free beer", despite no actual free beer being around. I am looking forward to see you there! regards. Philipp From peter at stuge.se Thu Sep 19 23:34:13 2013 From: peter at stuge.se (Peter Stuge) Date: Fri, 20 Sep 2013 01:34:13 +0200 Subject: UPDATE -- Osmocom Berlin User Group meeting -- NEXT MEETING In-Reply-To: <523B6FA3.1080701@gmx.de> References: <502d01a9.mirider@mirider.augusta.de> <20120818115942.GV29525@prithivi.gnumonks.org> <51AF0097.10402@gmx.de> <20130605121428.GA10030@nataraja.gnumonks.org> <523B6FA3.1080701@gmx.de> Message-ID: <20130919233413.762.qmail@stuge.se> dexter wrote: > This is the announcement for the next Osmocom Berlin meeting. > > Sep 25, 8pm @ CCC Berlin, Marienstr. 11, 10117 Berlin > > There is no formal presentation scheduled for this meeting. We might talk about some ideas for the 30C3 test network, and if there's a good feeling about it maybe work on code for SIM cards. //Peter From peter at stuge.se Mon Sep 16 13:19:46 2013 From: peter at stuge.se (Peter Stuge) Date: Mon, 16 Sep 2013 15:19:46 +0200 Subject: [PATCH] Add vty command for setting Access control classes In-Reply-To: <20130725160200.20126.qmail@stuge.se> References: <20130725160200.20126.qmail@stuge.se> <20130713055837.GA15044@xiaoyu.lan> <20130713094658.GF4901@xiaoyu.lan> <20130725145558.14794.qmail@stuge.se> Message-ID: <20130916131946.8936.qmail@stuge.se> Ivan Kluchnikov wrote: > > Yes, much better than before, but perhaps spend the half hour it > > takes to write that %d-%d parser using sscanf? > > If you implement %d-%d parser, I will change style of this VTY command. Peter Stuge wrote: > > If you implement %d-%d parser, I will change style of this VTY command. > > Here you go. Alexander Chemeris wrote: > > "If you write it we'll use it" != "now I have no time to do this" > > > > You can't be serious? > > Peter, there is a miscommunication here. Can you understand my confusion based on the quoted conversation? > What we meant - it would be nice to use your code, if it's integrated > into the libosmocore. I apologize if this was not conveyed properly .. > It's a nice feature and I don't think it's a lot of time to integrate > your code You're right that it isn't a lot of time, which is why I had expected that code which I sent on Jul 25th would be used already. (And my half hour estimate wasn't too far off, it took about 25 minutes to write plus 10 minutes to improve input validation the other day.) //Peter From maicon.kist at inf.ufrgs.br Thu Sep 5 12:41:19 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Thu, 5 Sep 2013 09:41:19 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: Hi list, I`m trying to discover where is the problem. So far, I`m putting some debug messages when the user makes a USSD call. I put a debug message in the function abis_rsl.c:rsl_data_request(struct msgb *, uint8_t). I notice that OpenBSC always restarts in the "return abis_rsl_sendmsg(msg)" function call (always). Also, the debug message I pyt in the abis_rsl_sendmsg function is never printed on screen. Right after the debug message I put in the abis_rsl.c:rsl_data_request(struct msgb *, uint8_t), this message is shown on screen: <0004> abis_rsl.c:634 (bts=0,trx=0,ts=0,ss=0) DEACTivate SACCH CMD. Curiously, right after this debug message, the abis_rsl_sendmsg function is also called. I don't know how the OpenBSC works, but what it seems to me is that two separate threads are calling this fuction, maybe this is the problem ? Do you guys know what I can try to do next? Best Regards, On Sat, Aug 31, 2013 at 11:25 AM, Maicon Kist wrote: > Hi List, (sorry for the flood). > > Any news about this error ? I'm planning to debug this error this weekend. > But, I'm not familiar with the code and would appreciate any suggestion of > where to start. > > > Best Regards, > > > On Mon, Aug 26, 2013 at 2:16 PM, Maicon Kist wrote: > >> Hi Alexander, >> >> attached is the capture realized. I started the capture and realized two >> USSD calls. >> If you need something, just ask. >> >> >> Beset Regards, >> >> >> On Mon, Aug 26, 2013 at 7:51 AM, Maicon Kist wrote: >> >>> Hi Alexander, >>> >>> I didn't even notice that the BTS restarts (it wasn't me). >>> >>> I will send the capture as soon as possible. >>> >>> Thank for all help. >>> >>> Best Regards, >>> >>> >>> >>> On Sun, Aug 25, 2013 at 4:50 AM, Alexander Chemeris < >>> alexander.chemeris at gmail.com> wrote: >>> >>>> Maicon, >>>> >>>> On Sun, Aug 25, 2013 at 12:53 AM, Maicon Kist >>>> wrote: >>>> > I think that line 10 is a log of the USSD call I made. >>>> >>>> And after that your BTS restarts for some reason. Is that because you >>>> manually restart it? >>>> >>>> > Hope it helps. If you need more information, just ask. If you need, I >>>> can >>>> > use other configurations or command options. >>>> >>>> Could you enable GSMTAP in OsmoBTS by adding "-i 127.0.0.1" parameter >>>> to osmobts-trx, capture traffic on the 4729 UDP port with >>>> Wireshark/tshark and send the capture here? >>>> >>>> It would be also helpful if you capture A-bis interface at the same >>>> capture (TCP port 3002/3003). >>>> >>>> PS List of the various TCP/UDP ports, used by Osmocom is available here: >>>> http://openbsc.osmocom.org/trac/wiki/PortNumbers >>>> >>>> -- >>>> Regards, >>>> Alexander Chemeris. >>>> CEO, Fairwaves LLC / ??? ??????? >>>> http://fairwaves.ru >>>> >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Sat Sep 7 16:48:50 2013 From: laforge at gnumonks.org (Harald Welte) Date: Sat, 7 Sep 2013 18:48:50 +0200 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: <20130907164850.GB6343@nataraja.gnumonks.org> Hi Maicon, I don't have much input, but: On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: > I don't know how the OpenBSC works, but what it seems to me is that two > separate threads are calling this fuction, maybe this is the problem ? Do > you guys know what I can try to do next? OpenBSC (and much of osmocom software) is a single-thread event-loop design, so there are no separete therads that are calling any function. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From maicon.kist at inf.ufrgs.br Sat Sep 7 19:02:35 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Sat, 7 Sep 2013 16:02:35 -0300 Subject: OpenBSC + USSD Application In-Reply-To: <20130907164850.GB6343@nataraja.gnumonks.org> References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: Thanks for you reply. I'm searching for the problem here, but is really hard for me. I captured some packets targeted to UDP port 4729. In this capture, I realize an USSD call. Whats bothering me is the packet number 37, the only with less than 83 bytes. Does anybody know if this may be a problem ? Thanks. On Sat, Sep 7, 2013 at 1:48 PM, Harald Welte wrote: > Hi Maicon, > > I don't have much input, but: > > On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: > > I don't know how the OpenBSC works, but what it seems to me is that two > > separate threads are calling this fuction, maybe this is the problem ? Do > > you guys know what I can try to do next? > > OpenBSC (and much of osmocom software) is a single-thread event-loop > design, so there are no separete therads that are calling any function. > > -- > - 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: port_4729.pcap Type: application/octet-stream Size: 15684 bytes Desc: not available URL: From alexander.chemeris at gmail.com Tue Sep 10 16:57:37 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Tue, 10 Sep 2013 20:57:37 +0400 Subject: OpenBSC + USSD Application In-Reply-To: References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: Maicon, Sorry for dropping off the discussion - busy time here. It seems we're seeing a similar issue here after we updated the code, so we'll check what's happening. Our older installs never had any USSD issues. On Sat, Sep 7, 2013 at 11:02 PM, Maicon Kist wrote: > Thanks for you reply. > > I'm searching for the problem here, but is really hard for me. > I captured some packets targeted to UDP port 4729. In this capture, I > realize an USSD call. Whats bothering me is the packet number 37, the only > with less than 83 bytes. > > Does anybody know if this may be a problem ? > > Thanks. > > > > > > > > On Sat, Sep 7, 2013 at 1:48 PM, Harald Welte wrote: >> >> Hi Maicon, >> >> I don't have much input, but: >> >> On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: >> > I don't know how the OpenBSC works, but what it seems to me is that two >> > separate threads are calling this fuction, maybe this is the problem ? >> > Do >> > you guys know what I can try to do next? >> >> OpenBSC (and much of osmocom software) is a single-thread event-loop >> design, so there are no separete therads that are calling any function. >> >> -- >> - Harald Welte >> http://laforge.gnumonks.org/ >> >> ============================================================================ >> "Privacy in residential applications is a desirable marketing option." >> (ETSI EN 300 175-7 Ch. >> A6) > > -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From maicon.kist at inf.ufrgs.br Wed Sep 18 15:57:56 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Wed, 18 Sep 2013 12:57:56 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: Hi Alexander, can you tell me in what version of OpenBSC the USSD is working? Thanks. On Tue, Sep 10, 2013 at 1:57 PM, Alexander Chemeris < alexander.chemeris at gmail.com> wrote: > Maicon, > > Sorry for dropping off the discussion - busy time here. > > It seems we're seeing a similar issue here after we updated the code, > so we'll check what's happening. Our older installs never had any USSD > issues. > > On Sat, Sep 7, 2013 at 11:02 PM, Maicon Kist > wrote: > > Thanks for you reply. > > > > I'm searching for the problem here, but is really hard for me. > > I captured some packets targeted to UDP port 4729. In this capture, I > > realize an USSD call. Whats bothering me is the packet number 37, the > only > > with less than 83 bytes. > > > > Does anybody know if this may be a problem ? > > > > Thanks. > > > > > > > > > > > > > > > > On Sat, Sep 7, 2013 at 1:48 PM, Harald Welte > wrote: > >> > >> Hi Maicon, > >> > >> I don't have much input, but: > >> > >> On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: > >> > I don't know how the OpenBSC works, but what it seems to me is that > two > >> > separate threads are calling this fuction, maybe this is the problem ? > >> > Do > >> > you guys know what I can try to do next? > >> > >> OpenBSC (and much of osmocom software) is a single-thread event-loop > >> design, so there are no separete therads that are calling any function. > >> > >> -- > >> - Harald Welte > >> http://laforge.gnumonks.org/ > >> > >> > ============================================================================ > >> "Privacy in residential applications is a desirable marketing option." > >> (ETSI EN 300 175-7 Ch. > >> A6) > > > > > > > > -- > Regards, > Alexander Chemeris. > CEO, Fairwaves LLC / ??? ??????? > http://fairwaves.ru > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Ivan.Kluchnikov at fairwaves.ru Wed Sep 18 17:18:24 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Wed, 18 Sep 2013 21:18:24 +0400 Subject: OpenBSC + USSD Application In-Reply-To: References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: Hi Maicon, Pull the last version of libosmocore from master branch and after that recompile libosmo-abis, openbsc and osmo-bts. 2013/9/18 Maicon Kist : > Hi Alexander, > > can you tell me in what version of OpenBSC the USSD is working? > > Thanks. > > > > On Tue, Sep 10, 2013 at 1:57 PM, Alexander Chemeris > wrote: >> >> Maicon, >> >> Sorry for dropping off the discussion - busy time here. >> >> It seems we're seeing a similar issue here after we updated the code, >> so we'll check what's happening. Our older installs never had any USSD >> issues. >> >> On Sat, Sep 7, 2013 at 11:02 PM, Maicon Kist >> wrote: >> > Thanks for you reply. >> > >> > I'm searching for the problem here, but is really hard for me. >> > I captured some packets targeted to UDP port 4729. In this capture, I >> > realize an USSD call. Whats bothering me is the packet number 37, the >> > only >> > with less than 83 bytes. >> > >> > Does anybody know if this may be a problem ? >> > >> > Thanks. >> > >> > >> > >> > >> > >> > >> > >> > On Sat, Sep 7, 2013 at 1:48 PM, Harald Welte >> > wrote: >> >> >> >> Hi Maicon, >> >> >> >> I don't have much input, but: >> >> >> >> On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: >> >> > I don't know how the OpenBSC works, but what it seems to me is that >> >> > two >> >> > separate threads are calling this fuction, maybe this is the problem >> >> > ? >> >> > Do >> >> > you guys know what I can try to do next? >> >> >> >> OpenBSC (and much of osmocom software) is a single-thread event-loop >> >> design, so there are no separete therads that are calling any function. >> >> >> >> -- >> >> - Harald Welte >> >> http://laforge.gnumonks.org/ >> >> >> >> >> >> ============================================================================ >> >> "Privacy in residential applications is a desirable marketing option." >> >> (ETSI EN 300 175-7 >> >> Ch. >> >> A6) >> > >> > >> >> >> >> -- >> Regards, >> Alexander Chemeris. >> CEO, Fairwaves LLC / ??? ??????? >> http://fairwaves.ru > > -- Regards, Ivan Kluchnikov. http://fairwaves.ru From maiconkist at gmail.com Wed Sep 18 17:24:25 2013 From: maiconkist at gmail.com (Maicon Kist) Date: Wed, 18 Sep 2013 14:24:25 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: Hi Ivan, thanks. Will try it tomorrow and give a feedback. Thanks. Best Regards, --- roses are #FF0000 violets are #0000FF On 18/09/2013, at 14:18, Ivan Kluchnikov wrote: > Hi Maicon, > > Pull the last version of libosmocore from master branch and after that > recompile libosmo-abis, openbsc and osmo-bts. > > 2013/9/18 Maicon Kist : >> Hi Alexander, >> >> can you tell me in what version of OpenBSC the USSD is working? >> >> Thanks. >> >> >> >> On Tue, Sep 10, 2013 at 1:57 PM, Alexander Chemeris >> wrote: >>> >>> Maicon, >>> >>> Sorry for dropping off the discussion - busy time here. >>> >>> It seems we're seeing a similar issue here after we updated the code, >>> so we'll check what's happening. Our older installs never had any USSD >>> issues. >>> >>> On Sat, Sep 7, 2013 at 11:02 PM, Maicon Kist >>> wrote: >>>> Thanks for you reply. >>>> >>>> I'm searching for the problem here, but is really hard for me. >>>> I captured some packets targeted to UDP port 4729. In this capture, I >>>> realize an USSD call. Whats bothering me is the packet number 37, the >>>> only >>>> with less than 83 bytes. >>>> >>>> Does anybody know if this may be a problem ? >>>> >>>> Thanks. >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Sat, Sep 7, 2013 at 1:48 PM, Harald Welte >>>> wrote: >>>>> >>>>> Hi Maicon, >>>>> >>>>> I don't have much input, but: >>>>> >>>>> On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: >>>>>> I don't know how the OpenBSC works, but what it seems to me is that >>>>>> two >>>>>> separate threads are calling this fuction, maybe this is the problem >>>>>> ? >>>>>> Do >>>>>> you guys know what I can try to do next? >>>>> >>>>> OpenBSC (and much of osmocom software) is a single-thread event-loop >>>>> design, so there are no separete therads that are calling any function. >>>>> >>>>> -- >>>>> - Harald Welte >>>>> http://laforge.gnumonks.org/ >>>>> >>>>> >>>>> ============================================================================ >>>>> "Privacy in residential applications is a desirable marketing option." >>>>> (ETSI EN 300 175-7 >>>>> Ch. >>>>> A6) >>>> >>>> >>> >>> >>> >>> -- >>> Regards, >>> Alexander Chemeris. >>> CEO, Fairwaves LLC / ??? ??????? >>> http://fairwaves.ru >> >> > > > > -- > Regards, > Ivan Kluchnikov. > http://fairwaves.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: From maicon.kist at inf.ufrgs.br Wed Sep 18 17:49:21 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Wed, 18 Sep 2013 14:49:21 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: Hi Ivan, thanks. Will try it tomorrow and give a feedback. Thanks. Best Regards, On 18/09/2013, at 14:18, Ivan Kluchnikov wrote: > Hi Maicon, > > Pull the last version of libosmocore from master branch and after that > recompile libosmo-abis, openbsc and osmo-bts. > > 2013/9/18 Maicon Kist : >> Hi Alexander, >> >> can you tell me in what version of OpenBSC the USSD is working? >> >> Thanks. >> >> >> >> On Tue, Sep 10, 2013 at 1:57 PM, Alexander Chemeris >> wrote: >>> >>> Maicon, >>> >>> Sorry for dropping off the discussion - busy time here. >>> >>> It seems we're seeing a similar issue here after we updated the code, >>> so we'll check what's happening. Our older installs never had any USSD >>> issues. >>> >>> On Sat, Sep 7, 2013 at 11:02 PM, Maicon Kist >>> wrote: >>>> Thanks for you reply. >>>> >>>> I'm searching for the problem here, but is really hard for me. >>>> I captured some packets targeted to UDP port 4729. In this capture, I >>>> realize an USSD call. Whats bothering me is the packet number 37, the >>>> only >>>> with less than 83 bytes. >>>> >>>> Does anybody know if this may be a problem ? >>>> >>>> Thanks. >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Sat, Sep 7, 2013 at 1:48 PM, Harald Welte >>>> wrote: >>>>> >>>>> Hi Maicon, >>>>> >>>>> I don't have much input, but: >>>>> >>>>> On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: >>>>>> I don't know how the OpenBSC works, but what it seems to me is that >>>>>> two >>>>>> separate threads are calling this fuction, maybe this is the problem >>>>>> ? >>>>>> Do >>>>>> you guys know what I can try to do next? >>>>> >>>>> OpenBSC (and much of osmocom software) is a single-thread event-loop >>>>> design, so there are no separete therads that are calling any function. >>>>> >>>>> -- >>>>> - Harald Welte >>>>> http://laforge.gnumonks.org/ >>>>> >>>>> >>>>> ============================================================================ >>>>> "Privacy in residential applications is a desirable marketing option." >>>>> (ETSI EN 300 175-7 >>>>> Ch. >>>>> A6) >>>> >>>> >>> >>> >>> >>> -- >>> Regards, >>> Alexander Chemeris. >>> CEO, Fairwaves LLC / ??? ??????? >>> http://fairwaves.ru >> >> > > > > -- > Regards, > Ivan Kluchnikov. > http://fairwaves.ru From maicon.kist at inf.ufrgs.br Thu Sep 19 12:23:52 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Thu, 19 Sep 2013 09:23:52 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: Hi Ivan, tred the latest version of openbsc (jolly/testing branch), osmocore-abis (master branch) and osmo-bts (jolly/trx branch). The problem I'm having continues. When I make a USSD call, osmo-nitb and osmo-trx show this error messages: ..... <000d> abis.c:428 Connection to BSC failed <0001> oml.c:249 OC=RADIO-CARRIER INST=(00,00,ff) AVAIL STATE Off line -> OK <0001> oml.c:256 OC=RADIO-CARRIER INST=(00,00,ff) OPER STATE Disabled -> Disabled <0001> oml.c:217 OC=RADIO-CARRIER INST=(00,00,ff) Tx STATE CHG REP <000d> abis.c:501 Abis socket closed. <000d> abis.c:433 Connection to BSC failed, retrying in 5 seconds. <0006> scheduler.c:2867 No more clock from traneiver <0006> scheduler.c:236 Exit scheduler for trx=0 <0006> scheduler.c:212 Init scheduler for trx=0 <0001> oml.c:249 OC=RADIO-CARRIER INST=(00,00,ff) AVAIL STATE OK -> Off line <0001> oml.c:256 OC=RADIO-CARRIER INST=(00,00,ff) OPER STATE Disabled -> Disabled <0001> oml.c:217 OC=RADIO-CARRIER INST=(00,00,ff) Tx STATE CHG REP <000d> abis.c:59 Link down, dropping message. ..... Any help ? Best Regards, On Wed, Sep 18, 2013 at 2:49 PM, Maicon Kist wrote: > Hi Ivan, > > thanks. Will try it tomorrow and give a feedback. Thanks. > > Best Regards, > > > On 18/09/2013, at 14:18, Ivan Kluchnikov > wrote: > > > Hi Maicon, > > > > Pull the last version of libosmocore from master branch and after that > > recompile libosmo-abis, openbsc and osmo-bts. > > > > 2013/9/18 Maicon Kist : > >> Hi Alexander, > >> > >> can you tell me in what version of OpenBSC the USSD is working? > >> > >> Thanks. > >> > >> > >> > >> On Tue, Sep 10, 2013 at 1:57 PM, Alexander Chemeris > >> wrote: > >>> > >>> Maicon, > >>> > >>> Sorry for dropping off the discussion - busy time here. > >>> > >>> It seems we're seeing a similar issue here after we updated the code, > >>> so we'll check what's happening. Our older installs never had any USSD > >>> issues. > >>> > >>> On Sat, Sep 7, 2013 at 11:02 PM, Maicon Kist > > >>> wrote: > >>>> Thanks for you reply. > >>>> > >>>> I'm searching for the problem here, but is really hard for me. > >>>> I captured some packets targeted to UDP port 4729. In this capture, I > >>>> realize an USSD call. Whats bothering me is the packet number 37, the > >>>> only > >>>> with less than 83 bytes. > >>>> > >>>> Does anybody know if this may be a problem ? > >>>> > >>>> Thanks. > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> On Sat, Sep 7, 2013 at 1:48 PM, Harald Welte > >>>> wrote: > >>>>> > >>>>> Hi Maicon, > >>>>> > >>>>> I don't have much input, but: > >>>>> > >>>>> On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: > >>>>>> I don't know how the OpenBSC works, but what it seems to me is that > >>>>>> two > >>>>>> separate threads are calling this fuction, maybe this is the problem > >>>>>> ? > >>>>>> Do > >>>>>> you guys know what I can try to do next? > >>>>> > >>>>> OpenBSC (and much of osmocom software) is a single-thread event-loop > >>>>> design, so there are no separete therads that are calling any > function. > >>>>> > >>>>> -- > >>>>> - Harald Welte > >>>>> http://laforge.gnumonks.org/ > >>>>> > >>>>> > >>>>> > ============================================================================ > >>>>> "Privacy in residential applications is a desirable marketing > option." > >>>>> (ETSI EN 300 175-7 > >>>>> Ch. > >>>>> A6) > >>>> > >>>> > >>> > >>> > >>> > >>> -- > >>> Regards, > >>> Alexander Chemeris. > >>> CEO, Fairwaves LLC / ??? ??????? > >>> http://fairwaves.ru > >> > >> > > > > > > > > -- > > Regards, > > Ivan Kluchnikov. > > http://fairwaves.ru > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas at eversberg.eu Thu Sep 19 12:52:46 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Thu, 19 Sep 2013 14:52:46 +0200 Subject: OpenBSC + USSD Application In-Reply-To: References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: <523AF39E.5030700@eversberg.eu> Maicon Kist wrote: > <000d> abis.c:428 Connection to BSC failed is bsc running? did you set correct ip to openbsc? what does openbsc output show when you start osmobts-trx? From maiconkist at gmail.com Thu Sep 19 13:42:49 2013 From: maiconkist at gmail.com (Maicon Kist) Date: Thu, 19 Sep 2013 10:42:49 -0300 Subject: OpenBSC + USSD Application In-Reply-To: <523AF39E.5030700@eversberg.eu> References: <20130907164850.GB6343@nataraja.gnumonks.org> <523AF39E.5030700@eversberg.eu> Message-ID: Hi Andreas, the output of the openbsc-trx: ((*)) | / \ OsmoBTS Using MAC address of eth0: xxxxxxx <0006> scheduler.c:212 Init scheduler for trx=0 <000a> trx_if.c:484 Open transceiver for trx=0 <000a> trx_if.c:495 Waiting for transceiver send clock % rtp bind-ip is now deprecated <0006> scheduler.c:2933 initial GSM clock received: fn=686409 <0001> oml.c:249 OC=RADIO-CARRIER INST=(00,00,ff) AVAIL STATE Power off -> OK <0001> oml.c:256 OC=RADIO-CARRIER INST=(00,00,ff) OPER STATE NULL -> Disabled <0001> oml.c:217 OC=RADIO-CARRIER INST=(00,00,ff) Tx STATE CHG REP <000d> abis.c:59 Link down, dropping message. <0001> oml.c:358 OC=RADIO-CARRIER INST=(00,00,ff) Tx SW ACT REP <000d> abis.c:59 Link down, dropping message. <0001> oml.c:249 OC=BASEBAND-TRANSCEIVER INST=(00,00,ff) AVAIL STATE Power off -> OK <0001> oml.c:217 OC=BASEBAND-TRANSCEIVER INST=(00,00,ff) Tx STATE CHG REP I started it with: osmobts-trx -c ~/.osmocom/osmo-bts.cfg and osmo-nitb: osmo-nitb -c ~/.osmocom/open-bsc.cfg -l ~/.osmocom/hlr.sqlite3 -P -m -C --debug=DRLL:DCC:DMM:DRR:DRSL:DNM with lcr and the transceiver started before these commands. The configuration files are the default provided in http://openbsc.osmocom.org/trac/wiki/network_from_scratch PS: Calls to 995 and 993 are working perfectly. Best Regards, abc On Thu, Sep 19, 2013 at 9:52 AM, Andreas Eversberg wrote: > Maicon Kist wrote: > > <000d> abis.c:428 Connection to BSC failed > is bsc running? did you set correct ip to openbsc? what does openbsc > output show when you start osmobts-trx? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From maicon.kist at inf.ufrgs.br Thu Sep 19 13:47:22 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Thu, 19 Sep 2013 10:47:22 -0300 Subject: OpenBSC + USSD Application In-Reply-To: <523AF39E.5030700@eversberg.eu> References: <20130907164850.GB6343@nataraja.gnumonks.org> <523AF39E.5030700@eversberg.eu> Message-ID: Hi Andreas, the output of the openbsc-trx: ((*)) | / \ OsmoBTS Using MAC address of eth0: xxxxxxx <0006> scheduler.c:212 Init scheduler for trx=0 <000a> trx_if.c:484 Open transceiver for trx=0 <000a> trx_if.c:495 Waiting for transceiver send clock % rtp bind-ip is now deprecated <0006> scheduler.c:2933 initial GSM clock received: fn=686409 <0001> oml.c:249 OC=RADIO-CARRIER INST=(00,00,ff) AVAIL STATE Power off -> OK <0001> oml.c:256 OC=RADIO-CARRIER INST=(00,00,ff) OPER STATE NULL -> Disabled <0001> oml.c:217 OC=RADIO-CARRIER INST=(00,00,ff) Tx STATE CHG REP <000d> abis.c:59 Link down, dropping message. <0001> oml.c:358 OC=RADIO-CARRIER INST=(00,00,ff) Tx SW ACT REP <000d> abis.c:59 Link down, dropping message. <0001> oml.c:249 OC=BASEBAND-TRANSCEIVER INST=(00,00,ff) AVAIL STATE Power off -> OK <0001> oml.c:217 OC=BASEBAND-TRANSCEIVER INST=(00,00,ff) Tx STATE CHG REP I started it with: osmobts-trx -c ~/.osmocom/osmo-bts.cfg and osmo-nitb: osmo-nitb -c ~/.osmocom/open-bsc.cfg -l ~/.osmocom/hlr.sqlite3 -P -m -C --debug=DRLL:DCC:DMM:DRR:DRSL:DNM with lcr and the transceiver started before these commands. The configuration files are the default provided in http://openbsc.osmocom.org/trac/wiki/network_from_scratch PS: Calls to 995 and 993 are working perfectly. Best Regards, On Thu, Sep 19, 2013 at 9:52 AM, Andreas Eversberg wrote: > Maicon Kist wrote: > > <000d> abis.c:428 Connection to BSC failed > is bsc running? did you set correct ip to openbsc? what does openbsc > output show when you start osmobts-trx? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Ivan.Kluchnikov at fairwaves.ru Thu Sep 19 13:08:43 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Thu, 19 Sep 2013 17:08:43 +0400 Subject: OpenBSC + USSD Application In-Reply-To: References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: Hi Maicon, It is strange, I will check with my installation. Now you can try to use more older version of libosmocore. Just checkout your libosmocore: git checkout a652abc5bf75435ba7f1c96ed914cf5805fc326f After that recompile and reinstall libosmocore, libosmo-abis, openbsc and osmo-bts. 2013/9/19 Maicon Kist : > Hi Ivan, > > tred the latest version of openbsc (jolly/testing branch), osmocore-abis > (master branch) and osmo-bts (jolly/trx branch). The problem I'm having > continues. When I make a USSD call, osmo-nitb and osmo-trx show this error > messages: > > ..... > <000d> abis.c:428 Connection to BSC failed > <0001> oml.c:249 OC=RADIO-CARRIER INST=(00,00,ff) AVAIL STATE Off line -> OK > <0001> oml.c:256 OC=RADIO-CARRIER INST=(00,00,ff) OPER STATE Disabled -> > Disabled > <0001> oml.c:217 OC=RADIO-CARRIER INST=(00,00,ff) Tx STATE CHG REP > <000d> abis.c:501 Abis socket closed. > <000d> abis.c:433 Connection to BSC failed, retrying in 5 seconds. > <0006> scheduler.c:2867 No more clock from traneiver > <0006> scheduler.c:236 Exit scheduler for trx=0 > <0006> scheduler.c:212 Init scheduler for trx=0 > <0001> oml.c:249 OC=RADIO-CARRIER INST=(00,00,ff) AVAIL STATE OK -> Off line > <0001> oml.c:256 OC=RADIO-CARRIER INST=(00,00,ff) OPER STATE Disabled -> > Disabled > <0001> oml.c:217 OC=RADIO-CARRIER INST=(00,00,ff) Tx STATE CHG REP > <000d> abis.c:59 Link down, dropping message. > ..... > > Any help ? > > Best Regards, > > > > > On Wed, Sep 18, 2013 at 2:49 PM, Maicon Kist > wrote: >> >> Hi Ivan, >> >> thanks. Will try it tomorrow and give a feedback. Thanks. >> >> Best Regards, >> >> >> On 18/09/2013, at 14:18, Ivan Kluchnikov >> wrote: >> >> > Hi Maicon, >> > >> > Pull the last version of libosmocore from master branch and after that >> > recompile libosmo-abis, openbsc and osmo-bts. >> > >> > 2013/9/18 Maicon Kist : >> >> Hi Alexander, >> >> >> >> can you tell me in what version of OpenBSC the USSD is working? >> >> >> >> Thanks. >> >> >> >> >> >> >> >> On Tue, Sep 10, 2013 at 1:57 PM, Alexander Chemeris >> >> wrote: >> >>> >> >>> Maicon, >> >>> >> >>> Sorry for dropping off the discussion - busy time here. >> >>> >> >>> It seems we're seeing a similar issue here after we updated the code, >> >>> so we'll check what's happening. Our older installs never had any USSD >> >>> issues. >> >>> >> >>> On Sat, Sep 7, 2013 at 11:02 PM, Maicon Kist >> >>> >> >>> wrote: >> >>>> Thanks for you reply. >> >>>> >> >>>> I'm searching for the problem here, but is really hard for me. >> >>>> I captured some packets targeted to UDP port 4729. In this capture, I >> >>>> realize an USSD call. Whats bothering me is the packet number 37, the >> >>>> only >> >>>> with less than 83 bytes. >> >>>> >> >>>> Does anybody know if this may be a problem ? >> >>>> >> >>>> Thanks. >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> On Sat, Sep 7, 2013 at 1:48 PM, Harald Welte >> >>>> wrote: >> >>>>> >> >>>>> Hi Maicon, >> >>>>> >> >>>>> I don't have much input, but: >> >>>>> >> >>>>> On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: >> >>>>>> I don't know how the OpenBSC works, but what it seems to me is that >> >>>>>> two >> >>>>>> separate threads are calling this fuction, maybe this is the >> >>>>>> problem >> >>>>>> ? >> >>>>>> Do >> >>>>>> you guys know what I can try to do next? >> >>>>> >> >>>>> OpenBSC (and much of osmocom software) is a single-thread event-loop >> >>>>> design, so there are no separete therads that are calling any >> >>>>> function. >> >>>>> >> >>>>> -- >> >>>>> - Harald Welte >> >>>>> http://laforge.gnumonks.org/ >> >>>>> >> >>>>> >> >>>>> >> >>>>> ============================================================================ >> >>>>> "Privacy in residential applications is a desirable marketing >> >>>>> option." >> >>>>> (ETSI EN 300 175-7 >> >>>>> Ch. >> >>>>> A6) >> >>>> >> >>>> >> >>> >> >>> >> >>> >> >>> -- >> >>> Regards, >> >>> Alexander Chemeris. >> >>> CEO, Fairwaves LLC / ??? ??????? >> >>> http://fairwaves.ru >> >> >> >> >> > >> > >> > >> > -- >> > Regards, >> > Ivan Kluchnikov. >> > http://fairwaves.ru >> >> > -- Regards, Ivan Kluchnikov. http://fairwaves.ru From maicon.kist at inf.ufrgs.br Thu Sep 19 18:11:23 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Thu, 19 Sep 2013 15:11:23 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: Hi Ivan, tried it. Same problem. Best Regards, On Thu, Sep 19, 2013 at 10:08 AM, Ivan Kluchnikov < Ivan.Kluchnikov at fairwaves.ru> wrote: > Hi Maicon, > > It is strange, I will check with my installation. > Now you can try to use more older version of libosmocore. > Just checkout your libosmocore: > git checkout a652abc5bf75435ba7f1c96ed914cf5805fc326f > After that recompile and reinstall libosmocore, libosmo-abis, openbsc > and osmo-bts. > > 2013/9/19 Maicon Kist : > > Hi Ivan, > > > > tred the latest version of openbsc (jolly/testing branch), osmocore-abis > > (master branch) and osmo-bts (jolly/trx branch). The problem I'm having > > continues. When I make a USSD call, osmo-nitb and osmo-trx show this > error > > messages: > > > > ..... > > <000d> abis.c:428 Connection to BSC failed > > <0001> oml.c:249 OC=RADIO-CARRIER INST=(00,00,ff) AVAIL STATE Off line > -> OK > > <0001> oml.c:256 OC=RADIO-CARRIER INST=(00,00,ff) OPER STATE Disabled -> > > Disabled > > <0001> oml.c:217 OC=RADIO-CARRIER INST=(00,00,ff) Tx STATE CHG REP > > <000d> abis.c:501 Abis socket closed. > > <000d> abis.c:433 Connection to BSC failed, retrying in 5 seconds. > > <0006> scheduler.c:2867 No more clock from traneiver > > <0006> scheduler.c:236 Exit scheduler for trx=0 > > <0006> scheduler.c:212 Init scheduler for trx=0 > > <0001> oml.c:249 OC=RADIO-CARRIER INST=(00,00,ff) AVAIL STATE OK -> Off > line > > <0001> oml.c:256 OC=RADIO-CARRIER INST=(00,00,ff) OPER STATE Disabled -> > > Disabled > > <0001> oml.c:217 OC=RADIO-CARRIER INST=(00,00,ff) Tx STATE CHG REP > > <000d> abis.c:59 Link down, dropping message. > > ..... > > > > Any help ? > > > > Best Regards, > > > > > > > > > > On Wed, Sep 18, 2013 at 2:49 PM, Maicon Kist > > wrote: > >> > >> Hi Ivan, > >> > >> thanks. Will try it tomorrow and give a feedback. Thanks. > >> > >> Best Regards, > >> > >> > >> On 18/09/2013, at 14:18, Ivan Kluchnikov > >> wrote: > >> > >> > Hi Maicon, > >> > > >> > Pull the last version of libosmocore from master branch and after that > >> > recompile libosmo-abis, openbsc and osmo-bts. > >> > > >> > 2013/9/18 Maicon Kist : > >> >> Hi Alexander, > >> >> > >> >> can you tell me in what version of OpenBSC the USSD is working? > >> >> > >> >> Thanks. > >> >> > >> >> > >> >> > >> >> On Tue, Sep 10, 2013 at 1:57 PM, Alexander Chemeris > >> >> wrote: > >> >>> > >> >>> Maicon, > >> >>> > >> >>> Sorry for dropping off the discussion - busy time here. > >> >>> > >> >>> It seems we're seeing a similar issue here after we updated the > code, > >> >>> so we'll check what's happening. Our older installs never had any > USSD > >> >>> issues. > >> >>> > >> >>> On Sat, Sep 7, 2013 at 11:02 PM, Maicon Kist > >> >>> > >> >>> wrote: > >> >>>> Thanks for you reply. > >> >>>> > >> >>>> I'm searching for the problem here, but is really hard for me. > >> >>>> I captured some packets targeted to UDP port 4729. In this > capture, I > >> >>>> realize an USSD call. Whats bothering me is the packet number 37, > the > >> >>>> only > >> >>>> with less than 83 bytes. > >> >>>> > >> >>>> Does anybody know if this may be a problem ? > >> >>>> > >> >>>> Thanks. > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> On Sat, Sep 7, 2013 at 1:48 PM, Harald Welte > > >> >>>> wrote: > >> >>>>> > >> >>>>> Hi Maicon, > >> >>>>> > >> >>>>> I don't have much input, but: > >> >>>>> > >> >>>>> On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: > >> >>>>>> I don't know how the OpenBSC works, but what it seems to me is > that > >> >>>>>> two > >> >>>>>> separate threads are calling this fuction, maybe this is the > >> >>>>>> problem > >> >>>>>> ? > >> >>>>>> Do > >> >>>>>> you guys know what I can try to do next? > >> >>>>> > >> >>>>> OpenBSC (and much of osmocom software) is a single-thread > event-loop > >> >>>>> design, so there are no separete therads that are calling any > >> >>>>> function. > >> >>>>> > >> >>>>> -- > >> >>>>> - Harald Welte > >> >>>>> http://laforge.gnumonks.org/ > >> >>>>> > >> >>>>> > >> >>>>> > >> >>>>> > ============================================================================ > >> >>>>> "Privacy in residential applications is a desirable marketing > >> >>>>> option." > >> >>>>> (ETSI EN 300 > 175-7 > >> >>>>> Ch. > >> >>>>> A6) > >> >>>> > >> >>>> > >> >>> > >> >>> > >> >>> > >> >>> -- > >> >>> Regards, > >> >>> Alexander Chemeris. > >> >>> CEO, Fairwaves LLC / ??? ??????? > >> >>> http://fairwaves.ru > >> >> > >> >> > >> > > >> > > >> > > >> > -- > >> > Regards, > >> > Ivan Kluchnikov. > >> > http://fairwaves.ru > >> > >> > > > > > > -- > Regards, > Ivan Kluchnikov. > http://fairwaves.ru > -------------- next part -------------- An HTML attachment was scrubbed... URL: From maicon.kist at inf.ufrgs.br Fri Sep 20 17:53:40 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Fri, 20 Sep 2013 14:53:40 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: <20130907164850.GB6343@nataraja.gnumonks.org> Message-ID: <13879EEE-A715-481F-B2B2-1C5C7BBC0574@inf.ufrgs.br> Hi list, USSD working! The problem was with the branches used. The working configuration is: libosmocore in branch jolly/7bit_ussd (I was using master) libosmo-abit in branch master openbsc in branch jolly/testing osmo-bts in branch jolly/trx (master didn't compile) Thanks for all your help. If somebody wants additional tests or configs, just ask. Best Regards, On 19/09/2013, at 15:11, Maicon Kist wrote: > Hi Ivan, > > tried it. Same problem. > > > > Best Regards, > > > > On Thu, Sep 19, 2013 at 10:08 AM, Ivan Kluchnikov wrote: > Hi Maicon, > > It is strange, I will check with my installation. > Now you can try to use more older version of libosmocore. > Just checkout your libosmocore: > git checkout a652abc5bf75435ba7f1c96ed914cf5805fc326f > After that recompile and reinstall libosmocore, libosmo-abis, openbsc > and osmo-bts. > > 2013/9/19 Maicon Kist : > > Hi Ivan, > > > > tred the latest version of openbsc (jolly/testing branch), osmocore-abis > > (master branch) and osmo-bts (jolly/trx branch). The problem I'm having > > continues. When I make a USSD call, osmo-nitb and osmo-trx show this error > > messages: > > > > ..... > > <000d> abis.c:428 Connection to BSC failed > > <0001> oml.c:249 OC=RADIO-CARRIER INST=(00,00,ff) AVAIL STATE Off line -> OK > > <0001> oml.c:256 OC=RADIO-CARRIER INST=(00,00,ff) OPER STATE Disabled -> > > Disabled > > <0001> oml.c:217 OC=RADIO-CARRIER INST=(00,00,ff) Tx STATE CHG REP > > <000d> abis.c:501 Abis socket closed. > > <000d> abis.c:433 Connection to BSC failed, retrying in 5 seconds. > > <0006> scheduler.c:2867 No more clock from traneiver > > <0006> scheduler.c:236 Exit scheduler for trx=0 > > <0006> scheduler.c:212 Init scheduler for trx=0 > > <0001> oml.c:249 OC=RADIO-CARRIER INST=(00,00,ff) AVAIL STATE OK -> Off line > > <0001> oml.c:256 OC=RADIO-CARRIER INST=(00,00,ff) OPER STATE Disabled -> > > Disabled > > <0001> oml.c:217 OC=RADIO-CARRIER INST=(00,00,ff) Tx STATE CHG REP > > <000d> abis.c:59 Link down, dropping message. > > ..... > > > > Any help ? > > > > Best Regards, > > > > > > > > > > On Wed, Sep 18, 2013 at 2:49 PM, Maicon Kist > > wrote: > >> > >> Hi Ivan, > >> > >> thanks. Will try it tomorrow and give a feedback. Thanks. > >> > >> Best Regards, > >> > >> > >> On 18/09/2013, at 14:18, Ivan Kluchnikov > >> wrote: > >> > >> > Hi Maicon, > >> > > >> > Pull the last version of libosmocore from master branch and after that > >> > recompile libosmo-abis, openbsc and osmo-bts. > >> > > >> > 2013/9/18 Maicon Kist : > >> >> Hi Alexander, > >> >> > >> >> can you tell me in what version of OpenBSC the USSD is working? > >> >> > >> >> Thanks. > >> >> > >> >> > >> >> > >> >> On Tue, Sep 10, 2013 at 1:57 PM, Alexander Chemeris > >> >> wrote: > >> >>> > >> >>> Maicon, > >> >>> > >> >>> Sorry for dropping off the discussion - busy time here. > >> >>> > >> >>> It seems we're seeing a similar issue here after we updated the code, > >> >>> so we'll check what's happening. Our older installs never had any USSD > >> >>> issues. > >> >>> > >> >>> On Sat, Sep 7, 2013 at 11:02 PM, Maicon Kist > >> >>> > >> >>> wrote: > >> >>>> Thanks for you reply. > >> >>>> > >> >>>> I'm searching for the problem here, but is really hard for me. > >> >>>> I captured some packets targeted to UDP port 4729. In this capture, I > >> >>>> realize an USSD call. Whats bothering me is the packet number 37, the > >> >>>> only > >> >>>> with less than 83 bytes. > >> >>>> > >> >>>> Does anybody know if this may be a problem ? > >> >>>> > >> >>>> Thanks. > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> On Sat, Sep 7, 2013 at 1:48 PM, Harald Welte > >> >>>> wrote: > >> >>>>> > >> >>>>> Hi Maicon, > >> >>>>> > >> >>>>> I don't have much input, but: > >> >>>>> > >> >>>>> On Thu, Sep 05, 2013 at 09:41:19AM -0300, Maicon Kist wrote: > >> >>>>>> I don't know how the OpenBSC works, but what it seems to me is that > >> >>>>>> two > >> >>>>>> separate threads are calling this fuction, maybe this is the > >> >>>>>> problem > >> >>>>>> ? > >> >>>>>> Do > >> >>>>>> you guys know what I can try to do next? > >> >>>>> > >> >>>>> OpenBSC (and much of osmocom software) is a single-thread event-loop > >> >>>>> design, so there are no separete therads that are calling any > >> >>>>> function. > >> >>>>> > >> >>>>> -- > >> >>>>> - Harald Welte > >> >>>>> http://laforge.gnumonks.org/ > >> >>>>> > >> >>>>> > >> >>>>> > >> >>>>> ============================================================================ > >> >>>>> "Privacy in residential applications is a desirable marketing > >> >>>>> option." > >> >>>>> (ETSI EN 300 175-7 > >> >>>>> Ch. > >> >>>>> A6) > >> >>>> > >> >>>> > >> >>> > >> >>> > >> >>> > >> >>> -- > >> >>> Regards, > >> >>> Alexander Chemeris. > >> >>> CEO, Fairwaves LLC / ??? ??????? > >> >>> http://fairwaves.ru > >> >> > >> >> > >> > > >> > > >> > > >> > -- > >> > Regards, > >> > Ivan Kluchnikov. > >> > http://fairwaves.ru > >> > >> > > > > > > -- > Regards, > Ivan Kluchnikov. > http://fairwaves.ru > -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Mon Sep 2 10:57:15 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 2 Sep 2013 12:57:15 +0200 Subject: OpenBSC with A-interface In-Reply-To: References: <20130825120253.GV27820@xiaoyu.lan> Message-ID: <20130902105715.GA16349@xiaoyu.lan> On Sun, Aug 25, 2013 at 07:03:40PM +0400, Dmitri Soloviev wrote: > Thank you > > but there are few things still unclear: > - why at A-bis interface BSC issues ip.accessMDCX with ip=0.0.0.0? is there > anything configured improperly? that is okay. The BTS has the OML/RSL connection. When the BTS is receivng a 0.0.0.0 on the RSL link, it is supposed to send the RTP to the IP address of the peer of the RSL link. > - so, UDP port is BSC side is predicted. but an endpoint at BTS side is > dynamically allocated.. is there a way to inform osmo-BSC_mgcp, or it just > replies to RTP from BTS? right. The osmo-bsc_mgcp will open two ports for each endpoint. One is facing toward the BTS and is predicatble, the other will be dynamically allocated and faces the network. From dmi3sol at gmail.com Mon Sep 2 12:46:09 2013 From: dmi3sol at gmail.com (Dmitri Soloviev) Date: Mon, 2 Sep 2013 16:46:09 +0400 Subject: OpenBSC with A-interface In-Reply-To: <20130902105715.GA16349@xiaoyu.lan> References: <20130825120253.GV27820@xiaoyu.lan> <20130902105715.GA16349@xiaoyu.lan> Message-ID: Thank you.. in fact, last night I did a hack, and it started to work http://www.opensigtran.org/bsc.html I'm doing without osmo-bsc_mgcp at all: after a chanel is being opened, my transcoder just replies the first rtp from bts and keeps this address as endpoint. I was about to clean the code (my ss7+ca and transcoder), publish it as well as discuss patches/hacks to openbsc I had to do: 1) in my case, OpenBSC makes BTS to talk to a predictable port at transcoder 2) I could not guess your reasons (as well as ways) to configure voice codecs within BSC, and hardcoded them within bssap_handleassingm_req() Hope to prepare a proper letter it in about a week BR, Dmitri On Mon, Sep 2, 2013 at 2:57 PM, Holger Hans Peter Freyther < holger at freyther.de> wrote: > On Sun, Aug 25, 2013 at 07:03:40PM +0400, Dmitri Soloviev wrote: > > Thank you > > > > but there are few things still unclear: > > > - why at A-bis interface BSC issues ip.accessMDCX with ip=0.0.0.0? is > there > > anything configured improperly? > > that is okay. The BTS has the OML/RSL connection. When the BTS is > receivng a 0.0.0.0 on the RSL link, it is supposed to send the RTP > to the IP address of the peer of the RSL link. > > > > - so, UDP port is BSC side is predicted. but an endpoint at BTS side is > > dynamically allocated.. is there a way to inform osmo-BSC_mgcp, or it > just > > replies to RTP from BTS? > > right. The osmo-bsc_mgcp will open two ports for each endpoint. One is > facing toward the BTS and is predicatble, the other will be dynamically > allocated and faces the network. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Sat Sep 7 16:53:08 2013 From: laforge at gnumonks.org (Harald Welte) Date: Sat, 7 Sep 2013 18:53:08 +0200 Subject: OpenBSC with A-interface In-Reply-To: References: <20130825120253.GV27820@xiaoyu.lan> <20130902105715.GA16349@xiaoyu.lan> Message-ID: <20130907165308.GC6343@nataraja.gnumonks.org> Hi Dmitry, On Mon, Sep 02, 2013 at 04:46:09PM +0400, Dmitri Soloviev wrote: > in fact, last night I did a hack, and it started to work > http://www.opensigtran.org/bsc.html congratulations! Thanks for your effort. > I'm doing without osmo-bsc_mgcp at all: after a chanel is being opened, my > transcoder just replies the first rtp from bts and keeps this address as > endpoint. Do you already have a plan for dealing with intra-bsc hand-over in this case? The advantage of having different RTP IP/Port on the A and the A-bis side is that the BTS can change due to intra-BTS or intra-BSC hand-over, while on the A interface everything remains stable/unchanged. > 1) in my case, OpenBSC makes BTS to talk to a predictable port at transcoder See my comment above. I'm not sure if this is the best solution moving forward... > 2) I could not guess your reasons (as well as ways) to configure voice > codecs within BSC, and hardcoded them within bssap_handleassingm_req() I'll let holger comment on that. My guess is that the MSC that was used didn't have enough flexibility in configuring the codecs so we override it in the BSC. > Hope to prepare a proper letter it in about a week Looking forard to it! 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 dmi3sol at gmail.com Sat Sep 7 20:33:04 2013 From: dmi3sol at gmail.com (Dmitri Soloviev) Date: Sun, 8 Sep 2013 00:33:04 +0400 Subject: OpenBSC with A-interface In-Reply-To: <20130907165308.GC6343@nataraja.gnumonks.org> References: <20130825120253.GV27820@xiaoyu.lan> <20130902105715.GA16349@xiaoyu.lan> <20130907165308.GC6343@nataraja.gnumonks.org> Message-ID: Hi Harald Thank you for a letter. as for intra-BSC handover, there could be 2 ways: - process them as inter-BSC. I'm pretty sure that in 2003 ip.access followed this way, as both nanoBTS involved were connected to a single BSC, and it was a gateway that processed handover - use osmo-bsc_mgcp as it was originally desired It doesn't make much difference: minor changes in transcoder control, as MGCP logic was just reduced. Meantime if the second way is chosen, I'll face the old problem again: I could not get how the endpoint from BTS is delivered to osmo-bsc_mgcp, and why it is lost in the particular deployment I'll appreciate your vision of codec management: reasons for keeping it at BSC side (and some key/example how to configure them), or permission to reduce this logic. If there is a demand to interact with a particular inflexible MSC, I would offer to filter out unsupported codecs in assignment procedure, keeping a single control point/decision maker Best Regards, Dmitri On Sat, Sep 7, 2013 at 8:53 PM, Harald Welte wrote: > Hi Dmitry, > > On Mon, Sep 02, 2013 at 04:46:09PM +0400, Dmitri Soloviev wrote: > > in fact, last night I did a hack, and it started to work > > http://www.opensigtran.org/bsc.html > > congratulations! Thanks for your effort. > > > I'm doing without osmo-bsc_mgcp at all: after a chanel is being opened, > my > > transcoder just replies the first rtp from bts and keeps this address as > > endpoint. > > Do you already have a plan for dealing with intra-bsc hand-over in this > case? The advantage of having different RTP IP/Port on the A and the > A-bis side is that the BTS can change due to intra-BTS or intra-BSC > hand-over, while on the A interface everything remains stable/unchanged. > > > 1) in my case, OpenBSC makes BTS to talk to a predictable port at > transcoder > > See my comment above. I'm not sure if this is the best solution moving > forward... > > > 2) I could not guess your reasons (as well as ways) to configure voice > > codecs within BSC, and hardcoded them within bssap_handleassingm_req() > > I'll let holger comment on that. My guess is that the MSC that was used > didn't have enough flexibility in configuring the codecs so we override > it in the BSC. > > > Hope to prepare a proper letter it in about a week > > Looking forard to it! > > Regards, > Harald > -- > - 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 jerlbeck at sysmocom.de Mon Sep 2 07:48:27 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 02 Sep 2013 09:48:27 +0200 Subject: [PATCH 2/6] vty: Add test to check vty node hierarchy and related commands In-Reply-To: <20130831134128.GF28152@xiaoyu.lan> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1377880443-25900-2-git-send-email-jerlbeck@sysmocom.de> <20130831134128.GF28152@xiaoyu.lan> Message-ID: <522442CB.7020800@sysmocom.de> On 08/31/2013 03:41 PM, Holger Hans Peter Freyther wrote: > On Fri, Aug 30, 2013 at 06:33:59PM +0200, Jacob Erlbeck wrote: > >> -class TestVTYNITB(TestVTYBase): >> + >> +class TestVTYGenericBTS(TestVTYBase): > Why BTS? NITB/BSC mostly define the BSC functionality. I would > call it TestVTYGenericBSC. I can change it locally if you do > not object. Oops, that was a typo. Thanks for finding and fixing. >> + def notIgnoredTest(self): >> + sys.stderr.write('Going to ignore the next assertion(s) due to known bugs\n') >> + return False > I am still a bit puzzled here. Is this statement still accurate? > Specially because this is used with a if/else statement. > That's just an intermediate to keep the tests running until refactoring is done. So I didn't put much effort into this. We could even remove it with PATCH 5/6 of this set. From jerlbeck at sysmocom.de Mon Sep 2 11:21:25 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 02 Sep 2013 13:21:25 +0200 Subject: [PATCH 3/6] vty: Generalize ournode_exit() and ournode_end() In-Reply-To: <20130831134756.GG28152@xiaoyu.lan> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1377880443-25900-3-git-send-email-jerlbeck@sysmocom.de> <20130831134756.GG28152@xiaoyu.lan> Message-ID: <522474B5.5070306@sysmocom.de> On 08/31/2013 03:47 PM, Holger Hans Peter Freyther wrote: > On Fri, Aug 30, 2013 at 06:34:00PM +0200, Jacob Erlbeck wrote: > >> Note that in config mode if the tree is searched along the nodes >> toward the config node and a command is not found this way, a >> rollback is done by just replacing the vty's node and index member >> variable by the saved old values which might break the whole thing, when >> there has been a free() on the way. > okay, but in this case the config parsing will fail too. So right > now we should be safe. Thanks for looking into this! > o The problem would rather arise in interactive mode when somebody mistypes a command. It don't know, why outer context searching is enabled in config mode only and if somebody someday would like to provide this in non-config sub-nodes, too. Even if not, the scheme used for UM2K (alloc() in the node command and free() in vty_go_parent()) must not be used for config nodes. Having the same function (vty_go_parent() ) for just looking up the outer nodes and unwinding the node contexts effectively forbids side-effects. Perhaps one could add an additional boolean parameter to select between both modes of operation and separate the search phase from the unwinding phase. > >> @@ -186,36 +130,24 @@ gDEFUN(ournode_exit, >> gDEFUN(ournode_end, >> ournode_end_cmd, "end", "End current mode and change to enable mode.") >> { >> + if (vty->node >= CONFIG_NODE) { > > this would be true for the OM2K node, which is not a configure node. > Can you elaborate why not using the 'is config node' predicate is not > necessary? The 'end' command only makes sense for node >= ENABLE_NODE. If must not be applied before the vty is in enabled mode, so it's explicitly a no-op in these cases. What I'm not sure about is whether the 'end' command should be available in the non-config nodes, too (or what's the pure cisco way of it). It doesn't 'end' the configuration then but it returns to the top node in a defined way, which might be helpful in automated scripting. >> def _testConfigNetworkTree(self): >> self.vty.enable() >> - self.vty.verify("configure terminal",['']) >> + self.assertTrue(self.vty.verify("configure terminal",[''])) > where is the change from self.vty.verify to self assertTrue coming > from? is this related to your change? > Not at all, it accidently went into that patch. I'd rather put it into the PATCH 2/6 'test' patch. From jerlbeck at sysmocom.de Mon Sep 2 11:17:14 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 2 Sep 2013 13:17:14 +0200 Subject: [PATCH 1/4] vty: Add test to check vty node hierarchy and related commands In-Reply-To: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378120637-20508-1-git-send-email-jerlbeck@sysmocom.de> These tests check for the availability of 'exit' and 'end' in each configuration node and for the node specific commands to traverse the tree. In addition, using these commands from within inner contexts is checked. This will detect problems, when an outer command word is a prefix of an inner command, like with 'mgcp' and 'mgcp-through-msc-ipa'. Several assertions are disabled due to inconsistencies and missing commands (see above). --- openbsc/tests/vty_test_runner.py | 155 +++++++++++++++++++++++++++++++++++++- 1 file changed, 152 insertions(+), 3 deletions(-) diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 87a45bb..e91d018 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -56,7 +56,53 @@ class TestVTYBase(unittest.TestCase): self.vty = None osmoutil.end_proc(self.proc) -class TestVTYNITB(TestVTYBase): + +class TestVTYGenericBSC(TestVTYBase): + + def checkForEndAndExit(self): + res = self.vty.command("list") + #print ('looking for "exit"\n') + self.assert_(res.find(' exit\r') > 0) + #print 'found "exit"\nlooking for "end"\n' + self.assert_(res.find(' end\r') > 0) + #print 'found "end"\n' + + def ignoredCheckForEndAndExit(self): + sys.stderr.write('Going to ignore the next assertion(s) due to known bugs\n') + try: + self.checkForEndAndExit() + except BaseException as e: + sys.stderr.write('Expected and ignored failure: %s\n' % (str(e))) + + def notIgnoredTest(self): + sys.stderr.write('Going to ignore the next assertion(s) due to known bugs\n') + return False + + + def _testConfigNetworkTree(self): + self.vty.enable() + self.assertTrue(self.vty.verify("configure terminal",[''])) + self.assertEquals(self.vty.node(), 'config') + self.ignoredCheckForEndAndExit() + self.assertTrue(self.vty.verify("network",[''])) + self.assertEquals(self.vty.node(), 'config-net') + self.checkForEndAndExit() + self.assertTrue(self.vty.verify("bts 0",[''])) + self.assertEquals(self.vty.node(), 'config-net-bts') + self.checkForEndAndExit() + self.assertTrue(self.vty.verify("trx 0",[''])) + self.assertEquals(self.vty.node(), 'config-net-bts-trx') + self.checkForEndAndExit() + self.assertTrue(self.vty.verify("exit",[''])) + self.assertEquals(self.vty.node(), 'config-net-bts') + self.assertTrue(self.vty.verify("exit",[''])) + self.assertEquals(self.vty.node(), 'config-net') + self.assertTrue(self.vty.verify("exit",[''])) + self.assertEquals(self.vty.node(), 'config') + self.assertTrue(self.vty.verify("exit",[''])) + self.assertTrue(self.vty.node() is None) + +class TestVTYNITB(TestVTYGenericBSC): def vty_command(self): return ["./src/osmo-nitb/osmo-nitb", "-c", @@ -65,6 +111,38 @@ class TestVTYNITB(TestVTYBase): def vty_app(self): return (4242, "./src/osmo-nitb/osmo-nitb", "OpenBSC", "nitb") + def testConfigNetworkTree(self): + self._testConfigNetworkTree() + + def testVtyTree(self): + self.vty.enable() + self.assertTrue(self.vty.verify("configure terminal", [''])) + self.assertEquals(self.vty.node(), 'config') + self.ignoredCheckForEndAndExit() + self.assertTrue(self.vty.verify('mncc-int', [''])) + self.assertEquals(self.vty.node(), 'config-mncc-int') + self.checkForEndAndExit() + self.assertTrue(self.vty.verify('exit', [''])) + self.assertEquals(self.vty.node(), 'config') + self.assertTrue(self.vty.verify('smpp', [''])) + self.assertEquals(self.vty.node(), 'config-smpp') + self.ignoredCheckForEndAndExit() + self.assertTrue(self.vty.verify("exit", [''])) + if self.notIgnoredTest(): + self.assertEquals(self.vty.node(), 'config') + else: + self.assertTrue(self.vty.verify("configure terminal", [''])) + self.assertTrue(self.vty.verify("exit", [''])) + self.assertTrue(self.vty.node() is None) + + # Check searching for outer node's commands + self.vty.command("configure terminal") + self.vty.command('mncc-int') + self.vty.command('smpp') + self.assertEquals(self.vty.node(), 'config-smpp') + self.vty.command('mncc-int') + self.assertEquals(self.vty.node(), 'config-mncc-int') + def testEnableDisablePeriodicLU(self): self.vty.enable() self.vty.command("configure terminal") @@ -88,7 +166,7 @@ class TestVTYNITB(TestVTYBase): self.assertEquals(res.find('periodic location update 60'), -1) self.assert_(res.find('no periodic location update') > 0) -class TestVTYBSC(TestVTYBase): +class TestVTYBSC(TestVTYGenericBSC): def vty_command(self): return ["./src/osmo-bsc/osmo-bsc", "-c", @@ -97,6 +175,41 @@ class TestVTYBSC(TestVTYBase): def vty_app(self): return (4242, "./src/osmo-bsc/osmo-bsc", "OsmoBSC", "bsc") + def testConfigNetworkTree(self): + self._testConfigNetworkTree() + + def testVtyTree(self): + self.vty.enable() + self.assertTrue(self.vty.verify("configure terminal", [''])) + self.assertEquals(self.vty.node(), 'config') + self.ignoredCheckForEndAndExit() + self.assertTrue(self.vty.verify("msc 0", [''])) + self.assertEquals(self.vty.node(), 'config-msc') + self.ignoredCheckForEndAndExit() + self.assertTrue(self.vty.verify("exit", [''])) + if self.notIgnoredTest(): + self.assertEquals(self.vty.node(), 'config') + else: + self.assertTrue(self.vty.verify("configure terminal", [''])) + self.assertTrue(self.vty.verify("bsc", [''])) + self.assertEquals(self.vty.node(), 'config-bsc') + self.ignoredCheckForEndAndExit() + self.assertTrue(self.vty.verify("exit", [''])) + if self.notIgnoredTest(): + self.assertEquals(self.vty.node(), 'config') + else: + self.assertTrue(self.vty.verify("configure terminal", [''])) + self.assertTrue(self.vty.verify("exit", [''])) + self.assertTrue(self.vty.node() is None) + + # Check searching for outer node's commands + self.vty.command("configure terminal") + self.vty.command('msc 0') + self.vty.command("bsc") + self.assertEquals(self.vty.node(), 'config-bsc') + self.vty.command("msc 0") + self.assertEquals(self.vty.node(), 'config-msc') + def testUssdNotifications(self): self.vty.enable() self.vty.command("configure terminal") @@ -128,7 +241,7 @@ class TestVTYBSC(TestVTYBase): self.assert_(res.find('no bsc-welcome-text') > 0) self.assertEquals(res.find('bsc-welcome-text Hello MS'), -1) -class TestVTYNAT(TestVTYBase): +class TestVTYNAT(TestVTYGenericBSC): def vty_command(self): return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-c", @@ -137,6 +250,42 @@ class TestVTYNAT(TestVTYBase): def vty_app(self): return (4244, "src/osmo-bsc_nat/osmo-bsc_nat", "OsmoBSCNAT", "nat") + def testVtyTree(self): + self.vty.enable() + self.assertTrue(self.vty.verify('configure terminal', [''])) + self.assertEquals(self.vty.node(), 'config') + self.ignoredCheckForEndAndExit() + self.assertTrue(self.vty.verify('mgcp', [''])) + self.assertEquals(self.vty.node(), 'config-mgcp') + self.checkForEndAndExit() + self.assertTrue(self.vty.verify('exit', [''])) + self.assertEquals(self.vty.node(), 'config') + self.assertTrue(self.vty.verify('nat', [''])) + self.assertEquals(self.vty.node(), 'config-nat') + self.checkForEndAndExit() + self.assertTrue(self.vty.verify('bsc 0', [''])) + self.assertEquals(self.vty.node(), 'config-nat-bsc') + self.checkForEndAndExit() + self.assertTrue(self.vty.verify('exit', [''])) + self.assertEquals(self.vty.node(), 'config-nat') + self.assertTrue(self.vty.verify('exit', [''])) + self.assertEquals(self.vty.node(), 'config') + self.assertTrue(self.vty.verify('exit', [''])) + self.assertTrue(self.vty.node() is None) + + # Check searching for outer node's commands + self.vty.command('configure terminal') + self.vty.command('mgcp') + self.vty.command('nat') + self.assertEquals(self.vty.node(), 'config-nat') + self.vty.command('line vty') + self.assertEquals(self.vty.node(), 'config-line') + self.vty.command('nat') + self.assertEquals(self.vty.node(), 'config-nat') + self.vty.command('bsc 0') + self.vty.command('line vty') + self.assertEquals(self.vty.node(), 'config-line') + def testRewriteNoRewrite(self): self.vty.enable() res = self.vty.command("configure terminal") -- 1.7.9.5 From jerlbeck at sysmocom.de Mon Sep 2 11:17:15 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 2 Sep 2013 13:17:15 +0200 Subject: [PATCH 2/4] vty: Generalize ournode_exit() and ournode_end() In-Reply-To: <1378120637-20508-1-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1378120637-20508-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378120637-20508-2-git-send-email-jerlbeck@sysmocom.de> ournode_exit() duplicates most of bsc_vty_go_parent(). This patch fixes the inconsistencies of both functions within bsc_vty_go_parent() and replaces the implementation of ournode_exit() by a call to it. This makes 'exit' behave exactly like ^D in all openbsc nodes. ournode_end() has been changed to walk through the intermediate nodes until one of the top nodes is reached. This allows for cleanups to be done on the way. Note that in config mode if the tree is searched along the nodes toward the config node and a command is not found this way, a rollback is done by just replacing the vty's node and index member variable by the saved old values which might break the whole thing, when there has been a free() on the way. --- openbsc/src/libcommon/common_vty.c | 140 ++++++++++-------------------------- 1 file changed, 36 insertions(+), 104 deletions(-) diff --git a/openbsc/src/libcommon/common_vty.c b/openbsc/src/libcommon/common_vty.c index 7342f14..948bd49 100644 --- a/openbsc/src/libcommon/common_vty.c +++ b/openbsc/src/libcommon/common_vty.c @@ -48,6 +48,7 @@ enum node_type bsc_vty_go_parent(struct vty *vty) /* set vty->index correctly ! */ struct gsm_bts *bts = vty->index; vty->index = bts->network; + vty->index_sub = NULL; } break; case TRX_NODE: @@ -56,6 +57,7 @@ enum node_type bsc_vty_go_parent(struct vty *vty) /* set vty->index correctly ! */ struct gsm_bts_trx *trx = vty->index; vty->index = trx->bts; + vty->index_sub = &trx->bts->description; } break; case TS_NODE: @@ -64,18 +66,19 @@ enum node_type bsc_vty_go_parent(struct vty *vty) /* set vty->index correctly ! */ struct gsm_bts_trx_ts *ts = vty->index; vty->index = ts->trx; + vty->index_sub = &ts->trx->description; } break; case OML_NODE: case OM2K_NODE: vty->node = ENABLE_NODE; + /* NOTE: this only works because it's not part of the config + * tree, where outer commands are searched via vty_go_parent() + * and only (!) executed when a matching one is found. + */ talloc_free(vty->index); vty->index = NULL; break; - case NAT_NODE: - vty->node = CONFIG_NODE; - vty->index = NULL; - break; case NAT_BSC_NODE: vty->node = NAT_NODE; { @@ -85,19 +88,31 @@ enum node_type bsc_vty_go_parent(struct vty *vty) break; case PGROUP_NODE: vty->node = NAT_NODE; + vty->index = NULL; break; case TRUNK_NODE: vty->node = MGCP_NODE; + vty->index = NULL; break; case SMPP_ESME_NODE: vty->node = SMPP_NODE; vty->index = NULL; break; case SMPP_NODE: + case MGCP_NODE: + case GBPROXY_NODE: + case SGSN_NODE: + case NAT_NODE: + case BSC_NODE: case MSC_NODE: case MNCC_INT_NODE: default: - vty->node = CONFIG_NODE; + if (bsc_vty_is_config_node(vty, vty->node)) + vty->node = CONFIG_NODE; + else + vty->node = ENABLE_NODE; + + vty->index = NULL; } return vty->node; @@ -107,78 +122,7 @@ enum node_type bsc_vty_go_parent(struct vty *vty) gDEFUN(ournode_exit, ournode_exit_cmd, "exit", "Exit current mode and down to previous mode\n") { - switch (vty->node) { - case GSMNET_NODE: - vty->node = CONFIG_NODE; - vty->index = NULL; - break; - case BTS_NODE: - vty->node = GSMNET_NODE; - { - /* set vty->index correctly ! */ - struct gsm_bts *bts = vty->index; - vty->index = bts->network; - vty->index_sub = NULL; - } - break; - case TRX_NODE: - vty->node = BTS_NODE; - { - /* set vty->index correctly ! */ - struct gsm_bts_trx *trx = vty->index; - vty->index = trx->bts; - vty->index_sub = &trx->bts->description; - } - break; - case TS_NODE: - vty->node = TRX_NODE; - { - /* set vty->index correctly ! */ - struct gsm_bts_trx_ts *ts = vty->index; - vty->index = ts->trx; - vty->index_sub = &ts->trx->description; - } - break; - case NAT_BSC_NODE: - vty->node = NAT_NODE; - { - struct bsc_config *bsc_config = vty->index; - vty->index = bsc_config->nat; - } - break; - case PGROUP_NODE: - vty->node = NAT_NODE; - break; - case SMPP_ESME_NODE: - vty->node = SMPP_NODE; - vty->index = NULL; - break; - case SMPP_NODE: - case MGCP_NODE: - case GBPROXY_NODE: - case SGSN_NODE: - case NAT_NODE: - case BSC_NODE: - vty->node = CONFIG_NODE; - vty->index = NULL; - break; - case OML_NODE: - case OM2K_NODE: - vty->node = ENABLE_NODE; - talloc_free(vty->index); - vty->index = NULL; - break; - case MSC_NODE: - case MNCC_INT_NODE: - vty->node = CONFIG_NODE; - break; - case TRUNK_NODE: - vty->node = MGCP_NODE; - vty->index = NULL; - break; - default: - break; - } + bsc_vty_go_parent (vty); return CMD_SUCCESS; } @@ -186,36 +130,24 @@ gDEFUN(ournode_exit, gDEFUN(ournode_end, ournode_end_cmd, "end", "End current mode and change to enable mode.") { - switch (vty->node) { - case VIEW_NODE: - case ENABLE_NODE: - /* Nothing to do. */ - break; - case CONFIG_NODE: - case GSMNET_NODE: - case BTS_NODE: - case TRX_NODE: - case TS_NODE: - case MGCP_NODE: - case TRUNK_NODE: - case GBPROXY_NODE: - case SGSN_NODE: - case VTY_NODE: - case NAT_NODE: - case NAT_BSC_NODE: - case PGROUP_NODE: - case MSC_NODE: - case MNCC_INT_NODE: - case SMPP_NODE: - case SMPP_ESME_NODE: - case BSC_NODE: + enum node_type last_node = CONFIG_NODE; + + if (vty->node >= CONFIG_NODE) { + /* Repeatedly call go_parent until a top node is reached. */ + while (vty->node > CONFIG_NODE) { + if (vty->node == last_node) { + /* Ensure termination, this shouldn't happen. */ + break; + } + last_node = vty->node; + bsc_vty_go_parent(vty); + } + vty_config_unlock(vty); - vty->node = ENABLE_NODE; + if (vty->node > ENABLE_NODE) + vty->node = ENABLE_NODE; vty->index = NULL; vty->index_sub = NULL; - break; - default: - break; } return CMD_SUCCESS; } -- 1.7.9.5 From holger at freyther.de Mon Sep 2 18:24:45 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 2 Sep 2013 20:24:45 +0200 Subject: [PATCH 2/4] vty: Generalize ournode_exit() and ournode_end() In-Reply-To: <1378120637-20508-2-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1378120637-20508-1-git-send-email-jerlbeck@sysmocom.de> <1378120637-20508-2-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130902182445.GA20535@xiaoyu.lan> On Mon, Sep 02, 2013 at 01:17:15PM +0200, Jacob Erlbeck wrote: Dear Jacob, thanks a lot for the updated patch! I have applied this patch locally (and updated the osmo-python-tests installation). > + if (vty->node >= CONFIG_NODE) { as discussed in the office, I have replaced this with "> ENABLE_NODE". Can you please double check tomorrow if I have done that correctly? > + /* Repeatedly call go_parent until a top node is reached. */ > + while (vty->node > CONFIG_NODE) { > + if (vty->node == last_node) { Shall we attempt to print a LOGL_ERROR if that happens? E.g. we would jump from the loop to the enable node. From jerlbeck at sysmocom.de Mon Sep 2 11:17:16 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 2 Sep 2013 13:17:16 +0200 Subject: [PATCH 3/4] vty: Use generic 'end' and 'exit' commands In-Reply-To: <1378120637-20508-1-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1378120637-20508-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378120637-20508-3-git-send-email-jerlbeck@sysmocom.de> Add bsc_install_default() and replace all install_default() This patch adds bsc_install_default() which calls install_default() and add 'exit' and 'end'. All other calls to install_default() are replaced by calls to bsc_install_default(). Since 'exit' and 'end' are now added automatically to each node, the explicit registrations of these commands are removed by this patch, too. The related tests succeed now without work-arounds (except for the 'config' node itself which is part of libosmocore). --- openbsc/include/openbsc/vty.h | 2 ++ openbsc/src/gprs/gb_proxy_vty.c | 4 +--- openbsc/src/gprs/sgsn_vty.c | 4 +--- openbsc/src/libbsc/abis_nm_vty.c | 3 +-- openbsc/src/libbsc/abis_om2000_vty.c | 3 +-- openbsc/src/libbsc/bsc_vty.c | 16 ++++------------ openbsc/src/libcommon/common_vty.c | 10 ++++++++++ openbsc/src/libmgcp/mgcp_vty.c | 8 ++------ openbsc/src/libmsc/smpp_vty.c | 4 ++-- openbsc/src/libmsc/vty_interface_layer3.c | 4 +--- openbsc/src/osmo-bsc/osmo_bsc_vty.c | 4 ++-- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 12 +++--------- openbsc/tests/vty_test_runner.py | 19 +++++-------------- 13 files changed, 35 insertions(+), 58 deletions(-) diff --git a/openbsc/include/openbsc/vty.h b/openbsc/include/openbsc/vty.h index 183fc25..f74516a 100644 --- a/openbsc/include/openbsc/vty.h +++ b/openbsc/include/openbsc/vty.h @@ -42,6 +42,8 @@ enum bsc_vty_node { extern int bsc_vty_is_config_node(struct vty *vty, int node); extern void bsc_replace_string(void *ctx, char **dst, const char *newstr); +void bsc_install_default(enum node_type node); + struct log_info; int bsc_vty_init(const struct log_info *cat); int bsc_vty_init_extra(void); diff --git a/openbsc/src/gprs/gb_proxy_vty.c b/openbsc/src/gprs/gb_proxy_vty.c index bfa1f3b..63546d3 100644 --- a/openbsc/src/gprs/gb_proxy_vty.c +++ b/openbsc/src/gprs/gb_proxy_vty.c @@ -82,9 +82,7 @@ int gbproxy_vty_init(void) install_element(CONFIG_NODE, &cfg_gbproxy_cmd); install_node(&gbproxy_node, config_write_gbproxy); - install_default(GBPROXY_NODE); - install_element(GBPROXY_NODE, &ournode_exit_cmd); - install_element(GBPROXY_NODE, &ournode_end_cmd); + bsc_install_default(GBPROXY_NODE); install_element(GBPROXY_NODE, &cfg_nsip_sgsn_nsei_cmd); return 0; diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index a4ba280..8106b7d 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -418,9 +418,7 @@ int sgsn_vty_init(void) install_element(CONFIG_NODE, &cfg_sgsn_cmd); install_node(&sgsn_node, config_write_sgsn); - install_default(SGSN_NODE); - install_element(SGSN_NODE, &ournode_exit_cmd); - install_element(SGSN_NODE, &ournode_end_cmd); + bsc_install_default(SGSN_NODE); install_element(SGSN_NODE, &cfg_sgsn_bind_addr_cmd); install_element(SGSN_NODE, &cfg_ggsn_remote_ip_cmd); //install_element(SGSN_NODE, &cfg_ggsn_remote_port_cmd); diff --git a/openbsc/src/libbsc/abis_nm_vty.c b/openbsc/src/libbsc/abis_nm_vty.c index fd60210..5db667d 100644 --- a/openbsc/src/libbsc/abis_nm_vty.c +++ b/openbsc/src/libbsc/abis_nm_vty.c @@ -183,8 +183,7 @@ int abis_nm_vty_init(void) install_element(ENABLE_NODE, &oml_classnum_inst_cmd); install_node(&oml_node, dummy_config_write); - install_default(OML_NODE); - install_element(OML_NODE, &ournode_exit_cmd); + bsc_install_default(OML_NODE); install_element(OML_NODE, &oml_chg_adm_state_cmd); install_element(OML_NODE, &oml_opstart_cmd); diff --git a/openbsc/src/libbsc/abis_om2000_vty.c b/openbsc/src/libbsc/abis_om2000_vty.c index 3df005b..eb8f4d5 100644 --- a/openbsc/src/libbsc/abis_om2000_vty.c +++ b/openbsc/src/libbsc/abis_om2000_vty.c @@ -445,8 +445,7 @@ int abis_om2k_vty_init(void) install_element(ENABLE_NODE, &om2k_classnum_inst_cmd); install_node(&om2k_node, dummy_config_write); - install_default(OM2K_NODE); - install_element(OM2K_NODE, &ournode_exit_cmd); + bsc_install_default(OM2K_NODE); install_element(OM2K_NODE, &om2k_reset_cmd); install_element(OM2K_NODE, &om2k_start_cmd); install_element(OM2K_NODE, &om2k_status_cmd); diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 45df90f..5748945 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -3002,9 +3002,7 @@ int bsc_vty_init(const struct log_info *cat) install_element(CONFIG_NODE, &cfg_net_cmd); install_node(&net_node, config_write_net); - install_default(GSMNET_NODE); - install_element(GSMNET_NODE, &ournode_exit_cmd); - install_element(GSMNET_NODE, &ournode_end_cmd); + bsc_install_default(GSMNET_NODE); install_element(GSMNET_NODE, &cfg_net_ncc_cmd); install_element(GSMNET_NODE, &cfg_net_mnc_cmd); install_element(GSMNET_NODE, &cfg_net_name_short_cmd); @@ -3040,9 +3038,7 @@ int bsc_vty_init(const struct log_info *cat) install_element(GSMNET_NODE, &cfg_bts_cmd); install_node(&bts_node, config_write_bts); - install_default(BTS_NODE); - install_element(BTS_NODE, &ournode_exit_cmd); - install_element(BTS_NODE, &ournode_end_cmd); + bsc_install_default(BTS_NODE); install_element(BTS_NODE, &cfg_bts_type_cmd); install_element(BTS_NODE, &cfg_description_cmd); install_element(BTS_NODE, &cfg_no_description_cmd); @@ -3102,9 +3098,7 @@ int bsc_vty_init(const struct log_info *cat) install_element(BTS_NODE, &cfg_trx_cmd); install_node(&trx_node, dummy_config_write); - install_default(TRX_NODE); - install_element(TRX_NODE, &ournode_exit_cmd); - install_element(TRX_NODE, &ournode_end_cmd); + bsc_install_default(TRX_NODE); install_element(TRX_NODE, &cfg_trx_arfcn_cmd); install_element(TRX_NODE, &cfg_description_cmd); install_element(TRX_NODE, &cfg_no_description_cmd); @@ -3116,9 +3110,7 @@ int bsc_vty_init(const struct log_info *cat) install_element(TRX_NODE, &cfg_ts_cmd); install_node(&ts_node, dummy_config_write); - install_default(TS_NODE); - install_element(TS_NODE, &ournode_exit_cmd); - install_element(TS_NODE, &ournode_end_cmd); + bsc_install_default(TS_NODE); install_element(TS_NODE, &cfg_ts_pchan_cmd); install_element(TS_NODE, &cfg_ts_pchan_compat_cmd); install_element(TS_NODE, &cfg_ts_tsc_cmd); diff --git a/openbsc/src/libcommon/common_vty.c b/openbsc/src/libcommon/common_vty.c index 948bd49..b5b77c4 100644 --- a/openbsc/src/libcommon/common_vty.c +++ b/openbsc/src/libcommon/common_vty.c @@ -174,3 +174,13 @@ void bsc_replace_string(void *ctx, char **dst, const char *newstr) talloc_free(*dst); *dst = talloc_strdup(ctx, newstr); } + +void bsc_install_default(enum node_type node) +{ + install_default (node); + + if (node > CONFIG_NODE) { + install_element(node, &ournode_exit_cmd); + install_element(node, &ournode_end_cmd); + } +} diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c index 833908a..9421f4f 100644 --- a/openbsc/src/libmgcp/mgcp_vty.c +++ b/openbsc/src/libmgcp/mgcp_vty.c @@ -786,9 +786,7 @@ int mgcp_vty_init(void) install_element(CONFIG_NODE, &cfg_mgcp_cmd); install_node(&mgcp_node, config_write_mgcp); - install_default(MGCP_NODE); - install_element(MGCP_NODE, &ournode_exit_cmd); - install_element(MGCP_NODE, &ournode_end_cmd); + bsc_install_default(MGCP_NODE); install_element(MGCP_NODE, &cfg_mgcp_local_ip_cmd); install_element(MGCP_NODE, &cfg_mgcp_bts_ip_cmd); install_element(MGCP_NODE, &cfg_mgcp_bind_ip_cmd); @@ -820,9 +818,7 @@ int mgcp_vty_init(void) install_element(MGCP_NODE, &cfg_mgcp_trunk_cmd); install_node(&trunk_node, config_write_trunk); - install_default(TRUNK_NODE); - install_element(TRUNK_NODE, &ournode_exit_cmd); - install_element(TRUNK_NODE, &ournode_end_cmd); + bsc_install_default(TRUNK_NODE); install_element(TRUNK_NODE, &cfg_trunk_payload_number_cmd); install_element(TRUNK_NODE, &cfg_trunk_payload_name_cmd); install_element(TRUNK_NODE, &cfg_trunk_payload_number_cmd_old); diff --git a/openbsc/src/libmsc/smpp_vty.c b/openbsc/src/libmsc/smpp_vty.c index 4829eb9..abf9733 100644 --- a/openbsc/src/libmsc/smpp_vty.c +++ b/openbsc/src/libmsc/smpp_vty.c @@ -487,7 +487,7 @@ static int config_write_esme(struct vty *v) int smpp_vty_init(void) { install_node(&smpp_node, config_write_smpp); - install_default(SMPP_NODE); + bsc_install_default(SMPP_NODE); install_element(CONFIG_NODE, &cfg_smpp_cmd); install_element(SMPP_NODE, &cfg_smpp_port_cmd); @@ -497,7 +497,7 @@ int smpp_vty_init(void) install_element(SMPP_NODE, &cfg_no_esme_cmd); install_node(&esme_node, config_write_esme); - install_default(SMPP_ESME_NODE); + bsc_install_default(SMPP_ESME_NODE); install_element(SMPP_ESME_NODE, &cfg_esme_passwd_cmd); install_element(SMPP_ESME_NODE, &cfg_esme_no_passwd_cmd); install_element(SMPP_ESME_NODE, &cfg_esme_route_pfx_cmd); diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index 79c3457..19c78ea 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -975,9 +975,7 @@ int bsc_vty_init_extra(void) install_element(CONFIG_NODE, &cfg_mncc_int_cmd); install_node(&mncc_int_node, config_write_mncc_int); - install_default(MNCC_INT_NODE); - install_element(MNCC_INT_NODE, &ournode_exit_cmd); - install_element(MNCC_INT_NODE, &ournode_end_cmd); + bsc_install_default(MNCC_INT_NODE); install_element(MNCC_INT_NODE, &mnccint_def_codec_f_cmd); install_element(MNCC_INT_NODE, &mnccint_def_codec_h_cmd); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index f6cf1a0..90b0a0c 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -609,7 +609,7 @@ int bsc_vty_init_extra(void) install_element(CONFIG_NODE, &cfg_net_bsc_cmd); install_node(&bsc_node, config_write_bsc); - install_default(BSC_NODE); + bsc_install_default(BSC_NODE); install_element(BSC_NODE, &cfg_net_bsc_mid_call_text_cmd); install_element(BSC_NODE, &cfg_net_bsc_mid_call_timeout_cmd); install_element(BSC_NODE, &cfg_net_rf_socket_cmd); @@ -617,7 +617,7 @@ int bsc_vty_init_extra(void) install_element(BSC_NODE, &cfg_net_no_rf_off_time_cmd); install_node(&msc_node, config_write_msc); - install_default(MSC_NODE); + bsc_install_default(MSC_NODE); install_element(MSC_NODE, &cfg_net_bsc_token_cmd); install_element(MSC_NODE, &cfg_net_bsc_ncc_cmd); install_element(MSC_NODE, &cfg_net_bsc_mcc_cmd); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 36a46f2..511d62a 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -1192,9 +1192,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) /* nat group */ install_element(CONFIG_NODE, &cfg_nat_cmd); install_node(&nat_node, config_write_nat); - install_default(NAT_NODE); - install_element(NAT_NODE, &ournode_exit_cmd); - install_element(NAT_NODE, &ournode_end_cmd); + bsc_install_default(NAT_NODE); install_element(NAT_NODE, &cfg_nat_msc_ip_cmd); install_element(NAT_NODE, &cfg_nat_msc_port_cmd); install_element(NAT_NODE, &cfg_nat_auth_time_cmd); @@ -1235,18 +1233,14 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element(NAT_NODE, &cfg_nat_pgroup_cmd); install_element(NAT_NODE, &cfg_nat_no_pgroup_cmd); install_node(&pgroup_node, config_write_pgroup); - install_default(PGROUP_NODE); - install_element(PGROUP_NODE, &ournode_exit_cmd); - install_element(PGROUP_NODE, &ournode_end_cmd); + bsc_install_default(PGROUP_NODE); install_element(PGROUP_NODE, &cfg_pgroup_lac_cmd); install_element(PGROUP_NODE, &cfg_pgroup_no_lac_cmd); /* BSC subgroups */ install_element(NAT_NODE, &cfg_bsc_cmd); install_node(&bsc_node, config_write_bsc); - install_default(NAT_BSC_NODE); - install_element(NAT_BSC_NODE, &ournode_exit_cmd); - install_element(NAT_BSC_NODE, &ournode_end_cmd); + bsc_install_default(NAT_BSC_NODE); install_element(NAT_BSC_NODE, &cfg_bsc_token_cmd); install_element(NAT_BSC_NODE, &cfg_bsc_lac_cmd); install_element(NAT_BSC_NODE, &cfg_bsc_no_lac_cmd); diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index e91d018..912f9f2 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -128,10 +128,7 @@ class TestVTYNITB(TestVTYGenericBSC): self.assertEquals(self.vty.node(), 'config-smpp') self.ignoredCheckForEndAndExit() self.assertTrue(self.vty.verify("exit", [''])) - if self.notIgnoredTest(): - self.assertEquals(self.vty.node(), 'config') - else: - self.assertTrue(self.vty.verify("configure terminal", [''])) + self.assertEquals(self.vty.node(), 'config') self.assertTrue(self.vty.verify("exit", [''])) self.assertTrue(self.vty.node() is None) @@ -185,20 +182,14 @@ class TestVTYBSC(TestVTYGenericBSC): self.ignoredCheckForEndAndExit() self.assertTrue(self.vty.verify("msc 0", [''])) self.assertEquals(self.vty.node(), 'config-msc') - self.ignoredCheckForEndAndExit() + self.checkForEndAndExit() self.assertTrue(self.vty.verify("exit", [''])) - if self.notIgnoredTest(): - self.assertEquals(self.vty.node(), 'config') - else: - self.assertTrue(self.vty.verify("configure terminal", [''])) + self.assertEquals(self.vty.node(), 'config') self.assertTrue(self.vty.verify("bsc", [''])) self.assertEquals(self.vty.node(), 'config-bsc') - self.ignoredCheckForEndAndExit() + self.checkForEndAndExit() self.assertTrue(self.vty.verify("exit", [''])) - if self.notIgnoredTest(): - self.assertEquals(self.vty.node(), 'config') - else: - self.assertTrue(self.vty.verify("configure terminal", [''])) + self.assertEquals(self.vty.node(), 'config') self.assertTrue(self.vty.verify("exit", [''])) self.assertTrue(self.vty.node() is None) -- 1.7.9.5 From holger at freyther.de Mon Sep 2 18:25:24 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 2 Sep 2013 20:25:24 +0200 Subject: [PATCH 3/4] vty: Use generic 'end' and 'exit' commands In-Reply-To: <1378120637-20508-3-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1378120637-20508-1-git-send-email-jerlbeck@sysmocom.de> <1378120637-20508-3-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130902182524.GB20535@xiaoyu.lan> On Mon, Sep 02, 2013 at 01:17:16PM +0200, Jacob Erlbeck wrote: > - if self.notIgnoredTest(): I have now removed the notIgnoredTest method from the test. It was unused after your fixes. From jerlbeck at sysmocom.de Mon Sep 2 11:17:17 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 2 Sep 2013 13:17:17 +0200 Subject: [PATCH 4/4] vty: Rename 'mgcp-through-msc-ipa' command to 'use-msc-ipa-for-mgcp' In-Reply-To: <1378120637-20508-1-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1378120637-20508-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378120637-20508-4-git-send-email-jerlbeck@sysmocom.de> Currently the 'mgcp' command fails in the 'config-nat' node, because it get confused with 'mgcp-through-msc-ipa' which is executed instead because of the prefix based command selection. Thus the latter command is renamed by this patch to avoid the common prefix. The workaround in the test suite is removed. --- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 10 +++++----- openbsc/tests/vty_test_runner.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 511d62a..125fbf1 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -152,7 +152,7 @@ static int config_write_nat(struct vty *vty) llist_for_each_entry(pgroup, &_nat->paging_groups, entry) write_pgroup_lst(vty, pgroup); if (_nat->mgcp_ipa) - vty_out(vty, " mgcp-through-msc-ipa%s", VTY_NEWLINE); + vty_out(vty, " use-msc-ipa-for-mgcp%s", VTY_NEWLINE); return CMD_SUCCESS; } @@ -754,9 +754,9 @@ DEFUN(cfg_nat_ussd_local, return CMD_SUCCESS; } -DEFUN(cfg_nat_mgcp_ipa, - cfg_nat_mgcp_ipa_cmd, - "mgcp-through-msc-ipa", +DEFUN(cfg_nat_use_ipa_for_mgcp, + cfg_nat_use_ipa_for_mgcp_cmd, + "use-msc-ipa-for-mgcp", "This needs to be set at start. Handle MGCP messages through " "the IPA protocol and not through the UDP socket.\n") { @@ -1209,7 +1209,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element(NAT_NODE, &cfg_nat_ussd_query_cmd); install_element(NAT_NODE, &cfg_nat_ussd_token_cmd); install_element(NAT_NODE, &cfg_nat_ussd_local_cmd); - install_element(NAT_NODE, &cfg_nat_mgcp_ipa_cmd); + install_element(NAT_NODE, &cfg_nat_use_ipa_for_mgcp_cmd); /* access-list */ install_element(NAT_NODE, &cfg_lst_imsi_allow_cmd); diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 912f9f2..e85dbe2 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -269,13 +269,13 @@ class TestVTYNAT(TestVTYGenericBSC): self.vty.command('mgcp') self.vty.command('nat') self.assertEquals(self.vty.node(), 'config-nat') - self.vty.command('line vty') - self.assertEquals(self.vty.node(), 'config-line') + self.vty.command('mgcp') + self.assertEquals(self.vty.node(), 'config-mgcp') self.vty.command('nat') self.assertEquals(self.vty.node(), 'config-nat') self.vty.command('bsc 0') - self.vty.command('line vty') - self.assertEquals(self.vty.node(), 'config-line') + self.vty.command('mgcp') + self.assertEquals(self.vty.node(), 'config-mgcp') def testRewriteNoRewrite(self): self.vty.enable() -- 1.7.9.5 From andreas at eversberg.eu Mon Sep 2 17:28:26 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Mon, 02 Sep 2013 19:28:26 +0200 Subject: l1-sap patches for osmo-bts Message-ID: <5224CABA.903@eversberg.eu> hi, i reworked my l1sap patches for osmo-bts. (they are the base for adding osmo-bts-trx model code, which allow support for OpenBTS transceivers, like UmTRX or Calypso-BTS.) each single patch was tested, if Sysmocom-BTS is still functioning after applying it, rather than testing all patches together. i do not send the patches to mailing list, since there are 21 patches, and i don't want to spam the list before i know that these patches are small enough to be reviewed and understood. the branch is jolly/l1sap_parts. please let me know, whether they require better description or finer splitting. regards, andreas from last path to first patch: commit 0c0229886f6f6eba029c044e4cac8b420d86cd1c Author: Andreas Eversberg Date: Sun Sep 1 12:30:52 2013 +0200 Remove obsolete gsmtap handling from osmo-bts-sysmo part. commit dfc8a3635e527960fa615c4ce7342e9739230a79 Author: Andreas Eversberg Date: Sun Jun 16 15:09:56 2013 +0200 sysmobts: Forward CMR from L1 (Phone) to RTP payload commit 8cfffc712914107fe8277c96ad3afb1891f25014 Author: Andreas Eversberg Date: Sun Sep 1 12:06:19 2013 +0200 Add gsmtap option to command line to main.c of osmo-bts-sysmo commit 8ca47efb9cf9861a2766c41b96469263e1e13ed9 Author: Andreas Eversberg Date: Sun Sep 1 12:04:49 2013 +0200 Move gsmtap VTY commands from osmo-bts-sysmo to common part commit 2653aee1604d1504d707c9ed264dcb5cdaf2b01d Author: Andreas Eversberg Date: Mon Jul 29 09:45:22 2013 +0200 Send primitives at PH-/MPH-/TCH-SAP interface via GSMTAP commit 66c08e87a2985ffd48e6d870ac6318c2b82a1476 Author: Andreas Eversberg Date: Sun Sep 1 11:57:07 2013 +0200 Move loopback control VTY commands from osmo-bts-sysmo to common part commit 8015bfcb3014c707bfe16ed4b52612e6fe377e75 Author: Andreas Eversberg Date: Thu Feb 14 11:17:58 2013 +0100 Correctly fill system information messages from BSC SI 5*/6 require L2 header of 0x03,0x03. All SI might be less than 23 octets, so they need to be filled with 0x2b. commit ebc180d0270293195c830193234608629b50bc03 Author: Andreas Eversberg Date: Sun Jun 16 13:26:14 2013 +0200 sysmobts: Clean up transitions for lchan cipher state There are three transitions: 1. LCHAN_CIPH_NONE -> LCHAN_CIPH_RX_REQ -> LCHAN_CIPH_RX_CONF It is used to enable ciphering in RX (uplink) direction only. 2. LCHAN_CIPH_RX_CONF -> LCHAN_CIPH_RX_CONF_TX_REQ -> LCHAN_CIPH_RXTX_CONF It is used to additionally enable ciphering in TX (downlink) direction. 3. LCHAN_CIPH_NONE -> LCHAN_CIPH_RXTX_REQ -> LCHAN_CIPH_RX_CONF_TX_REQ -> LCHAN_CIPH_RXTX_CONF It is used to enable ciphering in both TX and RX directions. This is used when the channel is activated with encryption already enabled. (assignment or handover) In order to follow the order of these transitions, the RX direction must always be set before the TX direction. If no cipher key is set (A5/0), ciphering is set to ALG 0, but lchan cipher state remains at LCHAN_CIPH_NONE. commit c5f478d8d6702961dfb74642108187e653a05775 Author: Andreas Eversberg Date: Sat Aug 31 20:30:40 2013 +0200 Add MEAS (MPH_INFO) IND message to PH-/MPH-/TCH-SAP interface This part moves processing of measurement infos from osmo-bts-sysmo to common part. commit ffc1cc39ea28b695b98eedd1d16bdd023e4a77ad Author: Andreas Eversberg Date: Sun Sep 1 11:09:20 2013 +0200 Add SDCCH/SACCH/FACCH messages to PH-/MPH-/TCH-SAP interface This part moves control channel message primitives from osmo-bts-sysmo to common part. In order to control ciphering fo BTS model, CIPHER (MPH_INFO) messages are used. commit adc84b8db3bff29b5c681e04e078ee6000e5f4bf Author: Andreas Eversberg Date: Sun Sep 1 10:08:15 2013 +0200 Add TCH messages to PH-/MPH-/TCH-SAP interface This part moves TCH handling from osmo-bts-sysmo to common part. The RTP handling is done at the common part, so they can be used by other BTS models. commit 2510e3f23ed4fa0a469484703c6b86574f175cdc Author: Andreas Eversberg Date: Sun Sep 1 09:19:45 2013 +0200 Move chan act/rel/modify from bts_model to PH-/MPH-/TCH-SAP interface This part replaces channel activation/deactivation/modification routines by MPH_INFO messages. commit b1df874be87cf09290a3dd0d95790bc74f3d09fa Author: Andreas Eversberg Date: Sun Sep 1 09:02:24 2013 +0200 Relace bts_model_get_time() by get_time() at common part commit f5b8b0de3303cefb06838991441e24c6d58e7aae Author: Andreas Eversberg Date: Sat Aug 31 19:49:12 2013 +0200 Add TIME (MPH_INFO) IND messages to PH-/MPH-/TCH-SAP interface This part moves GSM time handling from osmo-bts-sysmo part to common part. commit a8d8eac3924517842c69a8d2b8ea4d8f17ce2c3a Author: Andreas Eversberg Date: Fri Aug 30 08:48:38 2013 +0200 Add PDCH messages to PH-/MPH-/TCH-SAP interface This part moves PDTCH, PACCH and PTCCH message primitives from osmo-bts-sysmo to common part. commit ebcbe2f73078200317d5b8a134753a069f9c3572 Author: Andreas Eversberg Date: Fri Aug 30 08:03:09 2013 +0200 Add PCH/AGCH message to PH-/MPH-/TCH-SAP interface This part moves PCH and AGCH message primitives from osmo-bts-sysmo to common part. commit 0521a5b654251fcd9a2923c607c8dbad3bd44a30 Author: Andreas Eversberg Date: Fri Aug 30 07:46:30 2013 +0200 Add RACH message to PH-/MPH-/TCH-SAP interface This part moves RACH message primitives from osmo-bts-sysmo to common part. commit 2ee4f41d6c5fe78bb0c347e673e2411486f2bc3f Author: Andreas Eversberg Date: Mon Jul 29 09:42:23 2013 +0200 Add BCCH message to PH-/MPH-/TCH-SAP interface This first part moves BCCH message primitives from osmo-bts-sysmo to common part. A new file "common/l1sap.c" is introduced to implement handling of layer 1 messages from/to BTS model. commit 4db570049f7ef6f7604e504083e8a3b751b09d6c Author: Andreas Eversberg Date: Mon Jul 29 09:37:07 2013 +0200 Add header file of PH-/MPH-/TCH-SAP interface to common part of osmo-bts Instead of handling primitives directly at layer 1 specific code, osmo-bts handles primitives at common code. When all primitive are moved, the l1sap interface will: - receive PH-DATA indications and forward them to layer 2. - check for RF link loss and notify BSC. - receive TCH indications and forward them via RTP. - receive PH-RTS indications and send PH-DATA requests with content according to its logical channel. - receive TCH-RTS indications and send TCH requests with content received via RTP or loopback from TCH indications. - send MPH-INFO requests to activate, deactivate and modify logical channels and handle their confirms. - receive MPH-INFO indications with measurements from tranceiver. - forward received and transmitted PH-DATA to GSMTAP. commit ebb73d8cc333584d440398a7bed41f3584693f40 Author: Andreas Eversberg Date: Sun Jul 28 11:48:40 2013 +0200 sysmo-bts: Use correct boundaries of L1 msg when forwarding to L1 proxy In case of a headroom in a message, the 'head' pointer will not point to the actual data. commit 2ef39102fed2167014938221411055a43a1dd763 Author: Andreas Eversberg Date: Tue Feb 5 09:31:20 2013 +0100 Remove obsolete osmo-bts-bb code From holger at freyther.de Tue Sep 3 15:42:59 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 3 Sep 2013 17:42:59 +0200 Subject: l1-sap patches for osmo-bts In-Reply-To: <5224CABA.903@eversberg.eu> References: <5224CABA.903@eversberg.eu> Message-ID: <20130903154259.GB24355@xiaoyu.lan> On Mon, Sep 02, 2013 at 07:28:26PM +0200, Andreas Eversberg wrote: > hi, Dear Andreas, I skimmed through the changes. It is heading in a good direction but there is still a lack of structure. What I mean is that your patch is mostly adding code to already long methods. E.g. like this: + case OSMO_PRIM(PRIM_PH_DATA, PRIM_OP_INDICATION): + if (L1SAP_IS_CHAN_TCHF(chan_nr)) { + if (trx->ts[tn].pchan == GSM_PCHAN_PDCH) { + if (L1SAP_IS_PTCCH(fn)) { + if (l1sap->oph.primitive + == PRIM_OP_INDICATION) { + if (data[0] == 7) this is level six. And it is very difficult to understand like this. And just by looking at it, when would we use TCH/F on a PDCH? holger From andreas at eversberg.eu Wed Sep 4 07:16:59 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Wed, 04 Sep 2013 09:16:59 +0200 Subject: l1-sap patches for osmo-bts In-Reply-To: <20130903154259.GB24355@xiaoyu.lan> References: <5224CABA.903@eversberg.eu> <20130903154259.GB24355@xiaoyu.lan> Message-ID: <5226DE6B.9070305@eversberg.eu> Holger Hans Peter Freyther wrote: dear holger, thanx for looking at my pataches. > + case OSMO_PRIM(PRIM_PH_DATA, PRIM_OP_INDICATION): > + if (L1SAP_IS_CHAN_TCHF(chan_nr)) { > + if (trx->ts[tn].pchan == GSM_PCHAN_PDCH) { > + if (L1SAP_IS_PTCCH(fn)) { > + if (l1sap->oph.primitive > + == PRIM_OP_INDICATION) { > + if (data[0] == 7) > this is exactly what i want to avoid when doing the new patches. where did you see this? look at patch 2653aee1 [1], there i put GSMTAP forwarding for PDCH in a seperate function: + case OSMO_PRIM(PRIM_PH_DATA, PRIM_OP_INDICATION): + if (trx->ts[tn].pchan == GSM_PCHAN_PDCH) + rc = gsmtap_pdch(l1sap, &chan_type, &tn, &ss, &fn, &data, + &len); did i made some mistake when pushing it? the code you mentioned above was still in jolly/l1sap branch. i just removed that obsolete branch. regards, andreas [1] http://git.osmocom.org/osmo-bts/commit/?h=jolly/l1sap_parts&id=2653aee1604d1504d707c9ed264dcb5cdaf2b01d From jerlbeck at sysmocom.de Fri Sep 6 14:51:58 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Fri, 6 Sep 2013 16:51:58 +0200 Subject: [PATCH 1/3] vty: Rename is_config() to is_config_child() Message-ID: <1378479120-8491-1-git-send-email-jerlbeck@sysmocom.de> The function is_config() returns 0 for CONFIG_NODE. Since that node is a config node, the function is renamed to resolve this. --- src/vty/command.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vty/command.c b/src/vty/command.c index faa7c51..7f502db 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -147,7 +147,7 @@ static int cmp_desc(const void *p, const void *q) return strcmp(a->cmd, b->cmd); } -static int is_config(struct vty *vty) +static int is_config_child(struct vty *vty) { if (vty->node <= CONFIG_NODE) return 0; @@ -2050,7 +2050,7 @@ cmd_execute_command(vector vline, struct vty *vty, struct cmd_element **cmd, /* Go to parent for config nodes to attempt to find the right command */ while (ret != CMD_SUCCESS && ret != CMD_WARNING - && is_config(vty)) { + && is_config_child(vty)) { vty_go_parent(vty); ret = cmd_execute_command_real(vline, vty, cmd); tried = 1; @@ -2198,7 +2198,7 @@ int config_from_file(struct vty *vty, FILE * fp) /* Try again with setting node to CONFIG_NODE */ while (ret != CMD_SUCCESS && ret != CMD_WARNING && ret != CMD_ERR_NOTHING_TODO - && vty->node != CONFIG_NODE && is_config(vty)) { + && is_config_child(vty)) { vty_go_parent(vty); ret = cmd_execute_command_strict(vline, vty, NULL); } -- 1.7.9.5 From jerlbeck at sysmocom.de Fri Sep 6 14:51:59 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Fri, 6 Sep 2013 16:51:59 +0200 Subject: [PATCH 2/3] vty: Refactored vty_go_parent(), 'end' and 'exit' In-Reply-To: <1378479120-8491-1-git-send-email-jerlbeck@sysmocom.de> References: <1378479120-8491-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378479120-8491-2-git-send-email-jerlbeck@sysmocom.de> Put all 'exit' logic into vty_go_parent() and replace the implementations of 'exit' and 'end' by generic ones that use vty_go_parent(). --- src/vty/command.c | 57 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/vty/command.c b/src/vty/command.c index 7f502db..ae21864 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -1889,10 +1889,22 @@ enum node_type vty_go_parent(struct vty *vty) { assert(vty->node > CONFIG_NODE); - if (host.app_info->go_parent_cb) - host.app_info->go_parent_cb(vty); - else - vty->node = CONFIG_NODE; + switch (vty->node) { + case CONFIG_NODE: + break; + + case CFG_LOG_NODE: + case VTY_NODE: + vty->node = CONFIG_NODE; + break; + + default: + if (host.app_info->go_parent_cb) + host.app_info->go_parent_cb(vty); + else + vty->node = CONFIG_NODE; + break; + } return vty->node; } @@ -2266,13 +2278,9 @@ gDEFUN(config_exit, vty->node = ENABLE_NODE; vty_config_unlock(vty); break; - case VTY_NODE: - vty->node = CONFIG_NODE; - break; - case CFG_LOG_NODE: - vty->node = CONFIG_NODE; - break; default: + if (vty->node > CONFIG_NODE) + vty_go_parent (vty); break; } return CMD_SUCCESS; @@ -2282,19 +2290,24 @@ gDEFUN(config_exit, gDEFUN(config_end, config_end_cmd, "end", "End current mode and change to enable mode.") { - switch (vty->node) { - case VIEW_NODE: - case ENABLE_NODE: - /* Nothing to do. */ - break; - case CFG_LOG_NODE: - case CONFIG_NODE: - case VTY_NODE: + enum node_type last_node = CONFIG_NODE; + + if (vty->node > ENABLE_NODE) { + /* Repeatedly call go_parent until a top node is reached. */ + while (vty->node > CONFIG_NODE) { + if (vty->node == last_node) { + /* Ensure termination, this shouldn't happen. */ + break; + } + last_node = vty->node; + vty_go_parent(vty); + } + vty_config_unlock(vty); - vty->node = ENABLE_NODE; - break; - default: - break; + if (vty->node > ENABLE_NODE) + vty->node = ENABLE_NODE; + vty->index = NULL; + vty->index_sub = NULL; } return CMD_SUCCESS; } -- 1.7.9.5 From holger at freyther.de Sun Sep 8 08:48:05 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sun, 8 Sep 2013 10:48:05 +0200 Subject: [PATCH 2/3] vty: Refactored vty_go_parent(), 'end' and 'exit' In-Reply-To: <1378479120-8491-2-git-send-email-jerlbeck@sysmocom.de> References: <1378479120-8491-1-git-send-email-jerlbeck@sysmocom.de> <1378479120-8491-2-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130908084805.GB10602@xiaoyu.lan> On Fri, Sep 06, 2013 at 04:51:59PM +0200, Jacob Erlbeck wrote: > + enum node_type last_node = CONFIG_NODE; > + > + if (vty->node > ENABLE_NODE) { I moved the enum in here but that doesn't really change anything. Maybe we should have a <= ENABLE_NODE and exit early? But that is not important. From jerlbeck at sysmocom.de Fri Sep 6 14:52:00 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Fri, 6 Sep 2013 16:52:00 +0200 Subject: [PATCH 3/3] vty: Add vty_install_default() and use for the vty nodes In-Reply-To: <1378479120-8491-1-git-send-email-jerlbeck@sysmocom.de> References: <1378479120-8491-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378479120-8491-3-git-send-email-jerlbeck@sysmocom.de> This adds the vty_install_default() function that is basically the install_default() function plus the registration of the commands 'exit' and 'end'. The latter is only provided in subnodes of ENABLED_NODE and CONFIG_NONE. The VTY test program is extended to check these commands. Ticket: OW#952 --- include/osmocom/vty/command.h | 5 ++ src/vty/command.c | 18 ++++-- src/vty/logging_vty.c | 3 +- src/vty/vty.c | 2 +- tests/vty/vty_test.c | 124 +++++++++++++++++++++++++++++++++++++++++ tests/vty/vty_test.ok | 43 ++++++++++++++ 6 files changed, 188 insertions(+), 7 deletions(-) diff --git a/include/osmocom/vty/command.h b/include/osmocom/vty/command.h index 8fbb482..b3b3029 100644 --- a/include/osmocom/vty/command.h +++ b/include/osmocom/vty/command.h @@ -340,6 +340,11 @@ void install_element(enum node_type, struct cmd_element *); void install_element_ve(struct cmd_element *cmd); void sort_node(void); +/* This is similar to install_default() but it also creates + * 'exit' and 'end' commands. + */ +void vty_install_default(enum node_type); + /* Concatenates argv[shift] through argv[argc-1] into a single NUL-terminated string with a space between each element (allocated using XMALLOC(MTYPE_TMP)). Returns NULL if shift >= argc. */ diff --git a/src/vty/command.c b/src/vty/command.c index ae21864..658f508 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -3302,6 +3302,18 @@ void install_default(enum node_type node) install_element(node, &show_running_config_cmd); } +void vty_install_default(enum node_type node) +{ + install_default(node); + + install_element(node, &config_exit_cmd); + + if (node >= CONFIG_NODE) { + /* It's not a top node. */ + install_element(node, &config_end_cmd); + } +} + /** * \brief Write the current running config to a given file * \param[in] vty the vty of the code @@ -3380,8 +3392,7 @@ void cmd_init(int terminal) } if (terminal) { - install_element(ENABLE_NODE, &config_exit_cmd); - install_default(ENABLE_NODE); + vty_install_default(ENABLE_NODE); install_element(ENABLE_NODE, &config_disable_cmd); install_element(ENABLE_NODE, &config_terminal_cmd); install_element (ENABLE_NODE, ©_runningconfig_startupconfig_cmd); @@ -3395,8 +3406,7 @@ void cmd_init(int terminal) install_element(ENABLE_NODE, &config_terminal_no_length_cmd); install_element(ENABLE_NODE, &echo_cmd); - install_default(CONFIG_NODE); - install_element(CONFIG_NODE, &config_exit_cmd); + vty_install_default(CONFIG_NODE); } install_element(CONFIG_NODE, &hostname_cmd); diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index e17c7a8..64e49d7 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -677,8 +677,7 @@ void logging_vty_add_cmds(const struct log_info *cat) install_element_ve(&show_alarms_cmd); install_node(&cfg_log_node, config_write_log); - install_default(CFG_LOG_NODE); - install_element(CFG_LOG_NODE, &config_end_cmd); + vty_install_default(CFG_LOG_NODE); install_element(CFG_LOG_NODE, &logging_fltr_all_cmd); install_element(CFG_LOG_NODE, &logging_use_clr_cmd); install_element(CFG_LOG_NODE, &logging_prnt_timestamp_cmd); diff --git a/src/vty/vty.c b/src/vty/vty.c index 696766a..8bfc35c 100644 --- a/src/vty/vty.c +++ b/src/vty/vty.c @@ -1753,7 +1753,7 @@ void vty_init(struct vty_app_info *app_info) install_element(ENABLE_NODE, &terminal_monitor_cmd); install_element(ENABLE_NODE, &terminal_no_monitor_cmd); - install_default(VTY_NODE); + vty_install_default(VTY_NODE); install_element(VTY_NODE, &vty_login_cmd); install_element(VTY_NODE, &no_vty_login_cmd); } diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c index 2a9be84..e54a205 100644 --- a/tests/vty/vty_test.c +++ b/tests/vty/vty_test.c @@ -20,10 +20,19 @@ #include #include +#include +#include +#include + #include #include #include #include +#include +#include +#include + +static enum event last_vty_connection_event = -1; static void test_cmd_string_from_valstr(void) { @@ -43,9 +52,124 @@ static void test_cmd_string_from_valstr(void) talloc_free (cmd); } +static int do_vty_command(struct vty *vty, const char *cmd) +{ + vector vline; + int ret; + + printf("Going to execute '%s'\n", cmd); + vline = cmd_make_strvec(cmd); + ret = cmd_execute_command(vline, vty, NULL, 0); + cmd_free_strvec(vline); + printf("Returned: %d, Current node: %d '%s'\n", ret, vty->node, cmd_prompt(vty->node)); + return ret; +} + +/* Override the implementation from telnet_interface.c */ +void vty_event(enum event event, int sock, struct vty *vty) +{ + last_vty_connection_event = event; + + fprintf(stderr, "Got VTY event: %d\n", event); +} + +static void test_node_tree_structure(void) +{ + struct vty_app_info vty_info = { + .name = "VtyTest", + .version = 0, + .go_parent_cb = NULL, + .is_config_node = NULL, + }; + + const struct log_info_cat default_categories[] = {}; + + const struct log_info log_info = { + .cat = default_categories, + .num_cat = ARRAY_SIZE(default_categories), + }; + + struct vty *vty; + vector vline; + int sock[2]; + + printf("Going to test VTY node tree structure\n"); + + /* Fake logging. */ + osmo_init_logging(&log_info); + + vty_init(&vty_info); + + logging_vty_add_cmds(&log_info); + + /* Fake connection. */ + socketpair(AF_UNIX, SOCK_STREAM, 0, sock); + + vty = vty_create(sock[0], NULL); + + OSMO_ASSERT(vty != NULL); + + OSMO_ASSERT(do_vty_command(vty, "enable") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == ENABLE_NODE); + + OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CONFIG_NODE); + OSMO_ASSERT(do_vty_command(vty, "exit") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == ENABLE_NODE); + + OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CONFIG_NODE); + OSMO_ASSERT(do_vty_command(vty, "end") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == ENABLE_NODE); + + OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CONFIG_NODE); + OSMO_ASSERT(do_vty_command(vty, "log stderr") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CFG_LOG_NODE); + OSMO_ASSERT(do_vty_command(vty, "exit") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CONFIG_NODE); + OSMO_ASSERT(do_vty_command(vty, "log stderr") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CFG_LOG_NODE); + OSMO_ASSERT(do_vty_command(vty, "end") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == ENABLE_NODE); + + OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CONFIG_NODE); + OSMO_ASSERT(do_vty_command(vty, "line vty") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == VTY_NODE); + OSMO_ASSERT(do_vty_command(vty, "exit") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CONFIG_NODE); + OSMO_ASSERT(do_vty_command(vty, "line vty") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == VTY_NODE); + OSMO_ASSERT(do_vty_command(vty, "end") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == ENABLE_NODE); + + + /* Check searching the parents nodes for matching commands. */ + OSMO_ASSERT(do_vty_command(vty, "configure terminal") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CONFIG_NODE); + OSMO_ASSERT(do_vty_command(vty, "log stderr") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CFG_LOG_NODE); + OSMO_ASSERT(do_vty_command(vty, "line vty") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == VTY_NODE); + OSMO_ASSERT(do_vty_command(vty, "log stderr") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == CFG_LOG_NODE); + OSMO_ASSERT(do_vty_command(vty, "end") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == ENABLE_NODE); + + /* Check for final 'exit' (connection close). */ + OSMO_ASSERT(do_vty_command(vty, "exit") == CMD_SUCCESS); + OSMO_ASSERT(vty->node == ENABLE_NODE); + OSMO_ASSERT(vty->status == VTY_CLOSE); + + vty_close(vty); + OSMO_ASSERT(last_vty_connection_event == VTY_CLOSED); +} + int main(int argc, char **argv) { test_cmd_string_from_valstr(); + test_node_tree_structure(); printf("All tests passed\n"); return 0; diff --git a/tests/vty/vty_test.ok b/tests/vty/vty_test.ok index baec249..0ea2dab 100644 --- a/tests/vty/vty_test.ok +++ b/tests/vty/vty_test.ok @@ -1,3 +1,46 @@ Going to test vty_cmd_string_from_valstr() Tested with %s-strings, resulting cmd = '[prefix%s%s%s%s%s][foo%s%s%s%s%s][sep%s%s%s%s%s][bar%s%s%s%s%s][end%s%s%s%s%s]' +Going to test VTY node tree structure +Going to execute 'enable' +Returned: 0, Current node: 3 '%s# ' +Going to execute 'configure terminal' +Returned: 0, Current node: 4 '%s(config)# ' +Going to execute 'exit' +Returned: 0, Current node: 3 '%s# ' +Going to execute 'configure terminal' +Returned: 0, Current node: 4 '%s(config)# ' +Going to execute 'end' +Returned: 0, Current node: 3 '%s# ' +Going to execute 'configure terminal' +Returned: 0, Current node: 4 '%s(config)# ' +Going to execute 'log stderr' +Returned: 0, Current node: 7 '%s(config-log)# ' +Going to execute 'exit' +Returned: 0, Current node: 4 '%s(config)# ' +Going to execute 'log stderr' +Returned: 0, Current node: 7 '%s(config-log)# ' +Going to execute 'end' +Returned: 0, Current node: 3 '%s# ' +Going to execute 'configure terminal' +Returned: 0, Current node: 4 '%s(config)# ' +Going to execute 'line vty' +Returned: 0, Current node: 8 '%s(config-line)# ' +Going to execute 'exit' +Returned: 0, Current node: 4 '%s(config)# ' +Going to execute 'line vty' +Returned: 0, Current node: 8 '%s(config-line)# ' +Going to execute 'end' +Returned: 0, Current node: 3 '%s# ' +Going to execute 'configure terminal' +Returned: 0, Current node: 4 '%s(config)# ' +Going to execute 'log stderr' +Returned: 0, Current node: 7 '%s(config-log)# ' +Going to execute 'line vty' +Returned: 0, Current node: 8 '%s(config-line)# ' +Going to execute 'log stderr' +Returned: 0, Current node: 7 '%s(config-log)# ' +Going to execute 'end' +Returned: 0, Current node: 3 '%s# ' +Going to execute 'exit' +Returned: 0, Current node: 3 '%s# ' All tests passed -- 1.7.9.5 From holger at freyther.de Sun Sep 8 08:53:10 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sun, 8 Sep 2013 10:53:10 +0200 Subject: [PATCH 1/3] vty: Rename is_config() to is_config_child() In-Reply-To: <1378479120-8491-1-git-send-email-jerlbeck@sysmocom.de> References: <1378479120-8491-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130908085310.GA14267@xiaoyu.lan> On Fri, Sep 06, 2013 at 04:51:58PM +0200, Jacob Erlbeck wrote: Very nice patch set! thanks a lot. I am applying and pushing it now. holger From jerlbeck at sysmocom.de Tue Sep 10 07:07:31 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Tue, 10 Sep 2013 09:07:31 +0200 Subject: [PATCH 1/2] vty: Replace 'enum node_type' by 'int' for last_node Message-ID: <1378796852-3712-1-git-send-email-jerlbeck@sysmocom.de> In this case the last_node variable may hold values that are not in enum node_type, so int is used instead. --- src/vty/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vty/command.c b/src/vty/command.c index df2ffea..7f76ced 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -2291,7 +2291,7 @@ gDEFUN(config_exit, config_end_cmd, "end", "End current mode and change to enable mode.") { if (vty->node > ENABLE_NODE) { - enum node_type last_node = CONFIG_NODE; + int last_node = CONFIG_NODE; /* Repeatedly call go_parent until a top node is reached. */ while (vty->node > CONFIG_NODE) { -- 1.7.9.5 From jerlbeck at sysmocom.de Tue Sep 10 07:07:32 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Tue, 10 Sep 2013 09:07:32 +0200 Subject: [PATCH 2/2] vty: Allow vty_go_parent() in all nodes. In-Reply-To: <1378796852-3712-1-git-send-email-jerlbeck@sysmocom.de> References: <1378796852-3712-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378796852-3712-2-git-send-email-jerlbeck@sysmocom.de> This patch removes an assertion of node > CONFIG_NODE and changes the function to handle all nodes properly. For the sake of completeness, the generic exit command implementation is extended to work properly with all nodes, too. --- src/vty/command.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/vty/command.c b/src/vty/command.c index 7f76ced..38a32cf 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -29,7 +29,6 @@ Boston, MA 02111-1307, USA. */ #include #define _XOPEN_SOURCE #include -#include #include #include #include @@ -1884,21 +1883,31 @@ char **cmd_complete_command(vector vline, struct vty *vty, int *status) } /* return parent node */ -/* MUST eventually converge on CONFIG_NODE */ +/* + * MUST eventually converge either on CONFIG_NODE for every config node or + * on CONFIG_ENABLE for every other user defined node. + */ enum node_type vty_go_parent(struct vty *vty) { - assert(vty->node > CONFIG_NODE); - switch (vty->node) { + case AUTH_NODE: + case VIEW_NODE: + case ENABLE_NODE: case CONFIG_NODE: break; + case AUTH_ENABLE_NODE: + vty->node = VIEW_NODE; + break; + case CFG_LOG_NODE: case VTY_NODE: vty->node = CONFIG_NODE; break; default: + if (vty->node > CONFIG_NODE); + if (host.app_info->go_parent_cb) host.app_info->go_parent_cb(vty); else @@ -2267,6 +2276,7 @@ gDEFUN(config_exit, config_exit_cmd, "exit", "Exit current mode and down to previous mode\n") { switch (vty->node) { + case AUTH_NODE: case VIEW_NODE: case ENABLE_NODE: if (0) //vty_shell (vty)) -- 1.7.9.5 From holger at freyther.de Tue Sep 10 09:06:49 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 10 Sep 2013 11:06:49 +0200 Subject: [PATCH 2/2] vty: Allow vty_go_parent() in all nodes. In-Reply-To: <1378796852-3712-2-git-send-email-jerlbeck@sysmocom.de> References: <1378796852-3712-1-git-send-email-jerlbeck@sysmocom.de> <1378796852-3712-2-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130910090649.GC31205@xiaoyu.lan> On Tue, Sep 10, 2013 at 09:07:32AM +0200, Jacob Erlbeck wrote: > /* return parent node */ > -/* MUST eventually converge on CONFIG_NODE */ > +/* > + * MUST eventually converge either on CONFIG_NODE for every config node or > + * on CONFIG_ENABLE for every other user defined node. > + */ The comment is wrong. There is no CONFIG_ENABLE node but the comment sounds dangerous too. The ENABLE_NODE might be password protected and I would like to avoid a situation where we come from a 'child' of the VIEW_NODE and end in 'ENABLE_NODE'. From jerlbeck at sysmocom.de Tue Sep 10 11:31:28 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Tue, 10 Sep 2013 13:31:28 +0200 Subject: [PATCH 2/2] vty: Allow vty_go_parent() in all nodes. In-Reply-To: <20130910090649.GC31205@xiaoyu.lan> References: <1378796852-3712-1-git-send-email-jerlbeck@sysmocom.de> <1378796852-3712-2-git-send-email-jerlbeck@sysmocom.de> <20130910090649.GC31205@xiaoyu.lan> Message-ID: <522F0310.4080403@sysmocom.de> On 09/10/2013 11:06 AM, Holger Hans Peter Freyther wrote: > On Tue, Sep 10, 2013 at 09:07:32AM +0200, Jacob Erlbeck wrote: >> /* return parent node */ >> -/* MUST eventually converge on CONFIG_NODE */ >> +/* >> + * MUST eventually converge either on CONFIG_NODE for every config node or >> + * on CONFIG_ENABLE for every other user defined node. >> + */ > The comment is wrong. There is no CONFIG_ENABLE node but the You're right, it's ENABLE_NODE of course. > comment > sounds dangerous too. The ENABLE_NODE might be password protected and > I would like to avoid a situation where we come from a 'child' of the > VIEW_NODE and end in 'ENABLE_NODE'. The implementation cares about that (at least for the base nodes). It is not checked whether the go_parent callback does this and there isn't a way yet, to distinguish a view node from an enable node (since there is only is_config_child()/is_config_node() ). The comment isn't quite explicit about that, but 'user defined node' was meant to refer to node (id's) above CONFIG_NODE, and there aren't any of these nodes that are neither config nor enable (yet). OTOH, since that doesn't seem to be clear enough I'm going to reword it. Jacob From jerlbeck at sysmocom.de Tue Sep 10 12:04:54 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Tue, 10 Sep 2013 14:04:54 +0200 Subject: [PATCH] vty: Allow vty_go_parent() in all nodes. In-Reply-To: <1378796852-3712-2-git-send-email-jerlbeck@sysmocom.de> References: <1378796852-3712-2-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378814694-20277-1-git-send-email-jerlbeck@sysmocom.de> This patch removes an assertion of node > CONFIG_NODE and changes the function to handle all nodes properly. For the sake of completeness, the generic 'exit' command implementation is extended to work properly with all nodes, too. --- src/vty/command.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/vty/command.c b/src/vty/command.c index 7f76ced..d6a2c18 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -29,7 +29,6 @@ Boston, MA 02111-1307, USA. */ #include #define _XOPEN_SOURCE #include -#include #include #include #include @@ -1884,15 +1883,33 @@ char **cmd_complete_command(vector vline, struct vty *vty, int *status) } /* return parent node */ -/* MUST eventually converge on CONFIG_NODE */ +/* + * This function MUST eventually converge on a node when called repeatedly, + * there must not be any cycles. + * All 'config' nodes shall converge on CONFIG_NODE. + * All other 'enable' nodes shall converge on ENABLE_NODE. + * All 'view' only nodes shall converge on VIEW_NODE. + * All other nodes shall converge on themselves or it must be ensured, + * that the user's rights are not extended anyhow by calling this function. + * + * Note that these requirements also apply to all functions that are used + * as go_parent_cb. + * Note also that this function relies on the is_config_child callback to + * recognize non-config nodes if go_parent_cb is not set. + */ enum node_type vty_go_parent(struct vty *vty) { - assert(vty->node > CONFIG_NODE); - switch (vty->node) { + case AUTH_NODE: + case VIEW_NODE: + case ENABLE_NODE: case CONFIG_NODE: break; + case AUTH_ENABLE_NODE: + vty->node = VIEW_NODE; + break; + case CFG_LOG_NODE: case VTY_NODE: vty->node = CONFIG_NODE; @@ -1901,8 +1918,10 @@ enum node_type vty_go_parent(struct vty *vty) default: if (host.app_info->go_parent_cb) host.app_info->go_parent_cb(vty); - else + else if (is_config_child(vty)) vty->node = CONFIG_NODE; + else + vty->node = VIEW_NODE; break; } @@ -2267,6 +2286,7 @@ gDEFUN(config_exit, config_exit_cmd, "exit", "Exit current mode and down to previous mode\n") { switch (vty->node) { + case AUTH_NODE: case VIEW_NODE: case ENABLE_NODE: if (0) //vty_shell (vty)) -- 1.7.9.5 From alexander.chemeris at gmail.com Tue Sep 10 07:41:33 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Tue, 10 Sep 2013 11:41:33 +0400 Subject: Unbounded AGCH queue in OsmoBTS Message-ID: Hi all, We're moving this discussion to the mailing list, as it seems it is more generic and complex than we've thought initially. The issue arose when I started doing load testing of the OsmoTRX transceiver and disabled all gating in it. As a result, all incoming noise was processed as valid Normal Bursts and Access Bursts and sent up to OsmoBTS. This leads to a situation, similar to a RACH flood, when there are more RACH requests coming, than a BTS could reasonably process. And this leads to an unbounded increase of the AGCH queue in the BTS - it consumes a few Mb per minute. I think that this is the root cause of the issue we've seen at a Netherlands festival installation, when 20K phones suddenly started connecting to our station after official networks went down. When the amount of RACH requests exceeded available CCCH capacity (took <5 seconds), mobile phones stopped answering out IMM.ASS messages. Hypothesis is that the AGCH queue became so long, requests were sent too late for a phone to receive it. And thus no phones answered to our IMM.ASS messages. Unfortunately, I wasn't able to collect enough data to check this hypothesis during that time and we don't have another big festival on hands atm. An attached is a quick fix for the unbounded queue growth. It uses a hardcoded value for the maximum queue length, which is fine for our load testing, but not flexible enough for the real life usage. We should make the AGCH queue long enough to keep high performance. At the same time, it must not exceed MS timeout or _all_ IMM.ASS messages will miss their target MS's. We could make this parameter user-configurable on a BTS side, but it seems more reasonable to automatically calculate it, depending on the channel combination and timeout values. But this should be done on the BSC side. So the questions are: 1) what is a good way to calculate it? 2) should we configure this queue length over OML, or move the queue from BTS to BSC? -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru -------------- next part -------------- A non-text attachment was scrubbed... Name: osmobts-limit-immass-queue.patch Type: application/octet-stream Size: 1260 bytes Desc: not available URL: From andreas at eversberg.eu Tue Sep 10 09:04:48 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Tue, 10 Sep 2013 11:04:48 +0200 Subject: Unbounded AGCH queue in OsmoBTS In-Reply-To: References: Message-ID: <522EE0B0.5050405@eversberg.eu> Alexander Chemeris wrote: > 1) what is a good way to calculate it? > 2) should we configure this queue length over OML, or move the queue > from BTS to BSC? i suggest to use two queues: * IMM.ASS messages which grant access * IMM.ASS messages which reject access the first queue should have higher priority, because giving access to mobile stations will sooner or later resolve the rach flood. another suggestion is to use a stack, rather than a fifo. this will ensure that latest assigned/rejected channels are handled first. we don't need to consider how long the mobile will wait for the assign/reject message, so we don't need to define a specific stack size. the latest messages will always be sent out early enough. the stack should have a limit, so oldest messages are dropped, if new messages are added. i still have no good solution for the maximum stack size. From holger at freyther.de Tue Sep 10 09:21:58 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 10 Sep 2013 11:21:58 +0200 Subject: Unbounded AGCH queue in OsmoBTS In-Reply-To: References: Message-ID: <20130910092158.GD31205@xiaoyu.lan> On Tue, Sep 10, 2013 at 11:41:33AM +0400, Alexander Chemeris wrote: > Hi all, > > An attached is a quick fix for the unbounded queue growth. It uses a > hardcoded value for the maximum queue length, which is fine for our > load testing, but not flexible enough for the real life usage. We > should make the AGCH queue long enough to keep high performance. At > the same time, it must not exceed MS timeout or _all_ IMM.ASS messages > will miss their target MS's. > > We could make this parameter user-configurable on a BTS side, but it > seems more reasonable to automatically calculate it, depending on the > channel combination and timeout values. But this should be done on the > BSC side. So the questions are: > 1) what is a good way to calculate it? > 2) should we configure this queue length over OML, or move the queue > from BTS to BSC? I had a quick look at 12.21 and there doesn't appear to be anything for the AGCH. So we will need to calculate the size from the channel configuration but this should be fairly easy. The other topic is the question of fairnes? The first requests will fill the queue, and then we drop most of the requests. Can you implement the size calculation? From alexander.chemeris at gmail.com Tue Sep 10 09:55:47 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Tue, 10 Sep 2013 13:55:47 +0400 Subject: Unbounded AGCH queue in OsmoBTS In-Reply-To: <20130910092158.GD31205@xiaoyu.lan> References: <20130910092158.GD31205@xiaoyu.lan> Message-ID: On Tue, Sep 10, 2013 at 1:21 PM, Holger Hans Peter Freyther wrote: > On Tue, Sep 10, 2013 at 11:41:33AM +0400, Alexander Chemeris wrote: >> Hi all, >> >> An attached is a quick fix for the unbounded queue growth. It uses a >> hardcoded value for the maximum queue length, which is fine for our >> load testing, but not flexible enough for the real life usage. We >> should make the AGCH queue long enough to keep high performance. At >> the same time, it must not exceed MS timeout or _all_ IMM.ASS messages >> will miss their target MS's. >> >> We could make this parameter user-configurable on a BTS side, but it >> seems more reasonable to automatically calculate it, depending on the >> channel combination and timeout values. But this should be done on the >> BSC side. So the questions are: >> 1) what is a good way to calculate it? >> 2) should we configure this queue length over OML, or move the queue >> from BTS to BSC? > > I had a quick look at 12.21 and there doesn't appear to be anything > for the AGCH. So we will need to calculate the size from the channel > configuration but this should be fairly easy. The other topic is the > question of fairnes? The first requests will fill the queue, and then > we drop most of the requests. In a flood situation fairness doesn't make much sense, since most of the requests will be dropped and we will process random requests anyway. So the best situation for the flood case is actually to have a very short (zero?) queue to reduce queueing latency. From this point, Andreas' ide to use a stack instead of a queue makes perfect sense. > Can you implement the size calculation? I could, but I think you or Andreas will do this cleaner and with much less effort. I would rather spend my time on looking for other issues and implementing new features I have more experience with. PS While you're here - I remind you that I'm still waiting for the review of the SMS DB schema update code. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From holger at freyther.de Tue Sep 10 10:05:15 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 10 Sep 2013 12:05:15 +0200 Subject: Unbounded AGCH queue in OsmoBTS In-Reply-To: References: <20130910092158.GD31205@xiaoyu.lan> Message-ID: <20130910100515.GE31205@xiaoyu.lan> On Tue, Sep 10, 2013 at 01:55:47PM +0400, Alexander Chemeris wrote: > > > Can you implement the size calculation? > > I could, but I think you or Andreas will do this cleaner and with much > less effort. I would rather spend my time on looking for other issues > and implementing new features I have more experience with. I will not have time to work on this anytime soon. From alexander.chemeris at gmail.com Tue Sep 10 10:24:38 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Tue, 10 Sep 2013 14:24:38 +0400 Subject: Unbounded AGCH queue in OsmoBTS In-Reply-To: <20130910100515.GE31205@xiaoyu.lan> References: <20130910092158.GD31205@xiaoyu.lan> <20130910100515.GE31205@xiaoyu.lan> Message-ID: On Tue, Sep 10, 2013 at 2:05 PM, Holger Hans Peter Freyther wrote: > On Tue, Sep 10, 2013 at 01:55:47PM +0400, Alexander Chemeris wrote: >> >> > Can you implement the size calculation? >> >> I could, but I think you or Andreas will do this cleaner and with much >> less effort. I would rather spend my time on looking for other issues >> and implementing new features I have more experience with. > > I will not have time to work on this anytime soon. If Andreas don't implement the calculation, we'll go with a manually configured limit. Should be fine for most use cases. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From holger at freyther.de Tue Sep 10 12:50:28 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 10 Sep 2013 14:50:28 +0200 Subject: Unbounded AGCH queue in OsmoBTS In-Reply-To: References: <20130910092158.GD31205@xiaoyu.lan> <20130910100515.GE31205@xiaoyu.lan> Message-ID: <20130910125028.GF31205@xiaoyu.lan> On Tue, Sep 10, 2013 at 02:24:38PM +0400, Alexander Chemeris wrote: > > If Andreas don't implement the calculation, we'll go with a manually > configured limit. Should be fine for most use cases. come on, please don't be so lazy. From admin at manateeshome.com Tue Sep 10 23:01:04 2013 From: admin at manateeshome.com (Pierre Kim) Date: Wed, 11 Sep 2013 08:01:04 +0900 Subject: Nanobts 1900 for sale Message-ID: <02ee01ceae79$a1b40b10$e51c2130$@manateeshome.com> Hello, I have a nanoBTS 1900MHz GPRS model for sale. Please email me if interested. Regards, Pierre -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerlbeck at sysmocom.de Wed Sep 11 08:46:55 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 11 Sep 2013 10:46:55 +0200 Subject: [PATCH 1/4] ussd: Send USSD on call setup on MSC errors Message-ID: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> Send an USSD message to the mobile station requesting a connection for a call or a SMS when the link to the MSC is down or in the grace period. The messages can be set (and this feature activated) by setting bsc/missing-msc-text resp. msc/bsc-grace-text via the vty. The generation of both messages has been tested manually. Ticket: OW#957 --- openbsc/include/openbsc/osmo_bsc.h | 11 ++++- openbsc/include/openbsc/osmo_msc_data.h | 6 +++ openbsc/src/osmo-bsc/osmo_bsc_api.c | 58 ++++++++++++++++++++++++- openbsc/src/osmo-bsc/osmo_bsc_sccp.c | 16 ++++--- openbsc/src/osmo-bsc/osmo_bsc_vty.c | 71 +++++++++++++++++++++++++++++++ openbsc/tests/vty_test_runner.py | 35 ++++++++++++++- 6 files changed, 185 insertions(+), 12 deletions(-) diff --git a/openbsc/include/openbsc/osmo_bsc.h b/openbsc/include/openbsc/osmo_bsc.h index 1d216ac..1032daa 100644 --- a/openbsc/include/openbsc/osmo_bsc.h +++ b/openbsc/include/openbsc/osmo_bsc.h @@ -7,6 +7,13 @@ #define BSS_SEND_USSD 1 +enum bsc_con { + BSC_CON_SUCCESS, + BSC_CON_REJECT_NO_LINK, + BSC_CON_REJECT_RF_GRACE, + BSC_CON_NO_MEM, +}; + struct sccp_connection; struct osmo_msc_data; struct bsc_msc_connection; @@ -34,8 +41,8 @@ struct bsc_api *osmo_bsc_api(); int bsc_queue_for_msc(struct osmo_bsc_sccp_con *conn, struct msgb *msg); int bsc_open_connection(struct osmo_bsc_sccp_con *sccp, struct msgb *msg); -int bsc_create_new_connection(struct gsm_subscriber_connection *conn, - struct osmo_msc_data *msc); +enum bsc_con bsc_create_new_connection(struct gsm_subscriber_connection *conn, + struct osmo_msc_data *msc); int bsc_delete_connection(struct osmo_bsc_sccp_con *sccp); struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, struct msgb *); diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/osmo_msc_data.h index 86b4a84..9c312ca 100644 --- a/openbsc/include/openbsc/osmo_msc_data.h +++ b/openbsc/include/openbsc/osmo_msc_data.h @@ -86,6 +86,9 @@ struct osmo_msc_data { /* ussd msc connection lost text */ char *ussd_msc_lost_txt; + + /* ussd text when MSC has entered the grace period */ + char *ussd_grace_txt; }; /* @@ -103,6 +106,9 @@ struct osmo_bsc_data { char *rf_ctrl_name; struct osmo_bsc_rf *rf_ctrl; int auto_off_timeout; + + /* ussd text when there is no MSC available */ + char *ussd_no_msc_txt; }; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_api.c b/openbsc/src/osmo-bsc/osmo_bsc_api.c index df8c044..5eb3de6 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_api.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_api.c @@ -85,6 +85,48 @@ static void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn, queue_msg_or_return(resp); } +static void bsc_send_ussd_notification(struct gsm_subscriber_connection *conn, + struct msgb *msg, const char *text) +{ + struct gsm48_hdr *gh; + int8_t pdisc; + uint8_t mtype; + int drop_message = 1; + + if (! text) + return; + + if (! msg || msgb_l3len(msg) < sizeof(*gh)) { + return; + } + + gh = msgb_l3(msg); + pdisc = gh->proto_discr & 0x0f; + mtype = gh->msg_type & 0xbf; + + /* Is CM service request? */ + if (pdisc == GSM48_PDISC_MM && mtype == GSM48_MT_MM_CM_SERV_REQ) { + struct gsm48_service_request *cm; + + cm = (struct gsm48_service_request *) &gh->data[0]; + + /* Is type SMS or call? */ + if (cm->cm_service_type == GSM48_CMSERV_SMS) + drop_message = 0; + else if (cm->cm_service_type == GSM48_CMSERV_MO_CALL_PACKET) + drop_message = 0; + } + + if (drop_message) { + LOGP(DMSC, LOGL_DEBUG, "Skipping (not sending) USSD message: '%s'\n", text); + return; + } + + LOGP(DMSC, LOGL_INFO, "Sending USSD message: '%s'\n", text); + gsm0480_send_ussdNotify(conn, 1, text); + gsm0480_send_releaseComplete(conn); +} + /* * Instruct to reserve data for a new connectiom, create the complete * layer three message, send it to open the connection. @@ -100,6 +142,7 @@ static int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg msc = bsc_find_msc(conn, msg); if (!msc) { LOGP(DMSC, LOGL_ERROR, "Failed to find a MSC for a connection.\n"); + bsc_send_ussd_notification(conn, msg, conn->bts->network->bsc_data->ussd_no_msc_txt); return -1; } @@ -112,10 +155,23 @@ static int complete_layer3(struct gsm_subscriber_connection *conn, struct msgb *resp; uint16_t network_code; uint16_t country_code; + enum bsc_con ret; /* allocate resource for a new connection */ - if (bsc_create_new_connection(conn, msc) != 0) + ret = bsc_create_new_connection(conn, msc); + + if (ret != BSC_CON_SUCCESS) { + /* allocation has failed */ + if (ret == BSC_CON_REJECT_NO_LINK) { + bsc_send_ussd_notification(conn, msg, msc->ussd_msc_lost_txt); + } else if (ret == BSC_CON_REJECT_RF_GRACE) { + bsc_send_ussd_notification(conn, msg, msc->ussd_grace_txt); + } + return BSC_API_CONN_POL_REJECT; + } + + // check return value, if failed check msg for and send USSD network_code = get_network_code_for_msc(conn->sccp_con->msc); country_code = get_country_code_for_msc(conn->sccp_con->msc); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c index 87f415e..deda0be 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c @@ -188,35 +188,37 @@ int bsc_queue_for_msc(struct osmo_bsc_sccp_con *conn, struct msgb *msg) return 0; } -int bsc_create_new_connection(struct gsm_subscriber_connection *conn, +enum bsc_con bsc_create_new_connection(struct gsm_subscriber_connection *conn, struct osmo_msc_data *msc) { struct osmo_bsc_sccp_con *bsc_con; struct sccp_connection *sccp; /* This should not trigger */ - if (!msc->msc_con->is_authenticated) { + if (!msc || !msc->msc_con->is_authenticated) { + // VSAT link down LOGP(DMSC, LOGL_ERROR, "How did this happen? MSC is not connected. Dropping.\n"); - return -1; + return BSC_CON_REJECT_NO_LINK; } if (!bsc_grace_allow_new_connection(conn->bts->network, conn->bts)) { + // Approaching shore LOGP(DMSC, LOGL_NOTICE, "BSC in grace period. No new connections.\n"); - return -1; + return BSC_CON_REJECT_RF_GRACE; } sccp = sccp_connection_socket(); if (!sccp) { LOGP(DMSC, LOGL_ERROR, "Failed to allocate memory.\n"); - return -ENOMEM; + return BSC_CON_NO_MEM; } bsc_con = talloc_zero(conn->bts, struct osmo_bsc_sccp_con); if (!bsc_con) { LOGP(DMSC, LOGL_ERROR, "Failed to allocate.\n"); sccp_connection_free(sccp); - return -1; + return BSC_CON_NO_MEM; } /* callbacks */ @@ -237,7 +239,7 @@ int bsc_create_new_connection(struct gsm_subscriber_connection *conn, bsc_con->conn = conn; llist_add_tail(&bsc_con->entry, &active_connections); conn->sccp_con = bsc_con; - return 0; + return BSC_CON_SUCCESS; } int bsc_open_connection(struct osmo_bsc_sccp_con *conn, struct msgb *msg) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 90b0a0c..6f7cdbf 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -122,6 +122,11 @@ static void write_msc(struct vty *vty, struct osmo_msc_data *msc) else vty_out(vty, " no bsc-msc-lost-text%s", VTY_NEWLINE); + if (msc->ussd_grace_txt && msc->ussd_grace_txt[0]) + vty_out(vty, " bsc-grace-text %s%s", msc->ussd_grace_txt, VTY_NEWLINE); + else + vty_out(vty, " no bsc-grace-text%s", VTY_NEWLINE); + if (msc->audio_length != 0) { int i; @@ -182,6 +187,11 @@ static int config_write_bsc(struct vty *vty) vty_out(vty, " bsc-auto-rf-off %d%s", bsc->auto_off_timeout, VTY_NEWLINE); + if (bsc->ussd_no_msc_txt && bsc->ussd_no_msc_txt[0]) + vty_out(vty, " missing-msc-text %s%s", bsc->ussd_no_msc_txt, VTY_NEWLINE); + else + vty_out(vty, " no missing-msc-text%s", VTY_NEWLINE); + return CMD_SUCCESS; } @@ -417,6 +427,63 @@ DEFUN(cfg_net_msc_no_lost_ussd, return CMD_SUCCESS; } +DEFUN(cfg_net_msc_grace_ussd, + cfg_net_msc_grace_ussd_cmd, + "bsc-grace-text .TEXT", + "Set the USSD notification to be sent when the MSC has entered the grace period\n" "Text to be sent\n") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + char *str = argv_concat(argv, argc, 0); + if (!str) + return CMD_WARNING; + + bsc_replace_string(osmo_bsc_data(vty), &data->ussd_grace_txt, str); + talloc_free(str); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_msc_no_grace_ussd, + cfg_net_msc_no_grace_ussd_cmd, + "no bsc-grace-text", + NO_STR "Clear the USSD notification to be sent when the MSC has entered the grace period\n") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + + talloc_free(data->ussd_grace_txt); + data->ussd_grace_txt = 0; + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_bsc_missing_msc_ussd, + cfg_net_bsc_missing_msc_ussd_cmd, + "missing-msc-text .TEXT", + "Set the USSD notification to be send when a MSC has not been found.\n" "Text to be sent\n") +{ + struct osmo_bsc_data *data = osmo_bsc_data(vty); + char *txt = argv_concat(argv, argc, 0); + if (!txt) + return CMD_WARNING; + + bsc_replace_string(data, &data->ussd_no_msc_txt, txt); + talloc_free(txt); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_bsc_no_missing_msc_text, + cfg_net_bsc_no_missing_msc_text_cmd, + "no missing-msc-text", + NO_STR "Clear the USSD notification to be send when a MSC has not been found.\n") +{ + struct osmo_bsc_data *data = osmo_bsc_data(vty); + + talloc_free(data->ussd_no_msc_txt); + data->ussd_no_msc_txt = 0; + + return CMD_SUCCESS; +} + + DEFUN(cfg_net_msc_type, cfg_net_msc_type_cmd, "type (normal|local)", @@ -615,6 +682,8 @@ int bsc_vty_init_extra(void) install_element(BSC_NODE, &cfg_net_rf_socket_cmd); install_element(BSC_NODE, &cfg_net_rf_off_time_cmd); install_element(BSC_NODE, &cfg_net_no_rf_off_time_cmd); + install_element(BSC_NODE, &cfg_net_bsc_missing_msc_ussd_cmd); + install_element(BSC_NODE, &cfg_net_bsc_no_missing_msc_text_cmd); install_node(&msc_node, config_write_msc); bsc_install_default(MSC_NODE); @@ -631,6 +700,8 @@ int bsc_vty_init_extra(void) install_element(MSC_NODE, &cfg_net_msc_no_welcome_ussd_cmd); install_element(MSC_NODE, &cfg_net_msc_lost_ussd_cmd); install_element(MSC_NODE, &cfg_net_msc_no_lost_ussd_cmd); + install_element(MSC_NODE, &cfg_net_msc_grace_ussd_cmd); + install_element(MSC_NODE, &cfg_net_msc_no_grace_ussd_cmd); install_element(MSC_NODE, &cfg_net_msc_type_cmd); install_element(MSC_NODE, &cfg_net_msc_emerg_cmd); install_element(MSC_NODE, &cfg_net_msc_local_prefix_cmd); diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index ab9670c..460b70e 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -207,7 +207,7 @@ class TestVTYBSC(TestVTYGenericBSC): self.vty.command("msc 0") self.assertEquals(self.vty.node(), 'config-msc') - def testUssdNotifications(self): + def testUssdNotificationsMsc(self): self.vty.enable() self.vty.command("configure terminal") self.vty.command("msc") @@ -215,10 +215,12 @@ class TestVTYBSC(TestVTYGenericBSC): # Test invalid input self.vty.verify("bsc-msc-lost-text", ['% Command incomplete.']) self.vty.verify("bsc-welcome-text", ['% Command incomplete.']) + self.vty.verify("bsc-grace-text", ['% Command incomplete.']) # Enable USSD notifications self.vty.verify("bsc-msc-lost-text MSC disconnected", ['']) self.vty.verify("bsc-welcome-text Hello MS", ['']) + self.vty.verify("bsc-grace-text In grace period", ['']) # Verify settings res = self.vty.command("write terminal") @@ -226,17 +228,46 @@ class TestVTYBSC(TestVTYGenericBSC): self.assertEquals(res.find('no bsc-msc-lost-text'), -1) self.assert_(res.find('bsc-welcome-text Hello MS') > 0) self.assertEquals(res.find('no bsc-welcome-text'), -1) + self.assert_(res.find('bsc-grace-text In grace period') > 0) + self.assertEquals(res.find('no bsc-grace-text'), -1) # Now disable it.. self.vty.verify("no bsc-msc-lost-text", ['']) self.vty.verify("no bsc-welcome-text", ['']) + self.vty.verify("no bsc-grace-text", ['']) # Verify settings res = self.vty.command("write terminal") self.assertEquals(res.find('bsc-msc-lost-text MSC disconnected'), -1) self.assert_(res.find('no bsc-msc-lost-text') > 0) - self.assert_(res.find('no bsc-welcome-text') > 0) self.assertEquals(res.find('bsc-welcome-text Hello MS'), -1) + self.assert_(res.find('no bsc-welcome-text') > 0) + self.assertEquals(res.find('bsc-grace-text In grace period'), -1) + self.assert_(res.find('no bsc-grace-text') > 0) + + def testUssdNotificationsBsc(self): + self.vty.enable() + self.vty.command("configure terminal") + self.vty.command("bsc") + + # Test invalid input + self.vty.verify("missing-msc-text", ['% Command incomplete.']) + + # Enable USSD notifications + self.vty.verify("missing-msc-text No MSC found", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('missing-msc-text No MSC found') > 0) + self.assertEquals(res.find('no missing-msc-text'), -1) + + # Now disable it.. + self.vty.verify("no missing-msc-text", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assertEquals(res.find('missing-msc-text No MSC found'), -1) + self.assert_(res.find('no missing-msc-text') > 0) class TestVTYNAT(TestVTYGenericBSC): -- 1.7.9.5 From jerlbeck at sysmocom.de Wed Sep 11 08:46:56 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 11 Sep 2013 10:46:56 +0200 Subject: [PATCH 2/4] vty: Hide unconfigured BTS on 'write' In-Reply-To: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378889218-5195-2-git-send-email-jerlbeck@sysmocom.de> This prevents the application from crashing when there is a half configured BTS (e.g. by using the command 'bts 1' when there isn't a BTS 1) and the 'write' command is used. --- openbsc/src/libbsc/bsc_vty.c | 10 ++++++---- openbsc/tests/vty_test_runner.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 5748945..55564b6 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -598,11 +598,13 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) if (bts->excl_from_rf_lock) vty_out(vty, " rf-lock-exclude%s", VTY_NEWLINE); - if (bts->model->config_write_bts) - bts->model->config_write_bts(vty, bts); + if (bts->model) { + if (bts->model->config_write_bts) + bts->model->config_write_bts(vty, bts); - llist_for_each_entry(trx, &bts->trx_list, list) - config_write_trx_single(vty, trx); + llist_for_each_entry(trx, &bts->trx_list, list) + config_write_trx_single(vty, trx); + } } static int config_write_bts(struct vty *v) diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 460b70e..7f71288 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -88,6 +88,17 @@ class TestVTYGenericBSC(TestVTYBase): self.assertTrue(self.vty.verify("trx 0",[''])) self.assertEquals(self.vty.node(), 'config-net-bts-trx') self.checkForEndAndExit() + self.vty.command("write terminal") + self.assertTrue(self.vty.verify("exit",[''])) + self.assertEquals(self.vty.node(), 'config-net-bts') + self.assertTrue(self.vty.verify("exit",[''])) + self.assertTrue(self.vty.verify("bts 1",[''])) + self.assertEquals(self.vty.node(), 'config-net-bts') + self.checkForEndAndExit() + self.assertTrue(self.vty.verify("trx 1",[''])) + self.assertEquals(self.vty.node(), 'config-net-bts-trx') + self.checkForEndAndExit() + self.vty.command("write terminal") self.assertTrue(self.vty.verify("exit",[''])) self.assertEquals(self.vty.node(), 'config-net-bts') self.assertTrue(self.vty.verify("exit",[''])) -- 1.7.9.5 From peter at stuge.se Thu Sep 12 03:23:59 2013 From: peter at stuge.se (Peter Stuge) Date: Thu, 12 Sep 2013 05:23:59 +0200 Subject: [PATCH 2/4] vty: Hide unconfigured BTS on 'write' In-Reply-To: <1378889218-5195-2-git-send-email-jerlbeck@sysmocom.de> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> <1378889218-5195-2-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130912032359.26335.qmail@stuge.se> Jacob Erlbeck wrote: > +++ b/openbsc/src/libbsc/bsc_vty.c > @@ -598,11 +598,13 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) > if (bts->excl_from_rf_lock) > vty_out(vty, " rf-lock-exclude%s", VTY_NEWLINE); > > - if (bts->model->config_write_bts) > - bts->model->config_write_bts(vty, bts); > + if (bts->model) { > + if (bts->model->config_write_bts) > + bts->model->config_write_bts(vty, bts); > > - llist_for_each_entry(trx, &bts->trx_list, list) > - config_write_trx_single(vty, trx); > + llist_for_each_entry(trx, &bts->trx_list, list) > + config_write_trx_single(vty, trx); > + } > } My personal taste is to test all required conditions and exit early if they aren't met. That way, it's easy to get an overview of all conditions, before the "meat" of the function takes place. It also avoids one level of nesting for each condition. The patch would in this case become quite simple: + if (!bts->model) + return; (Maybe even if (!bts || !bts->model) ..) //Peter From holger at freyther.de Thu Sep 12 06:07:54 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 12 Sep 2013 08:07:54 +0200 Subject: [PATCH 2/4] vty: Hide unconfigured BTS on 'write' In-Reply-To: <20130912032359.26335.qmail@stuge.se> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> <1378889218-5195-2-git-send-email-jerlbeck@sysmocom.de> <20130912032359.26335.qmail@stuge.se> Message-ID: <20130912060754.GA22410@xiaoyu.lan> On Thu, Sep 12, 2013 at 05:23:59AM +0200, Peter Stuge wrote: > > My personal taste is to test all required conditions and exit early > if they aren't met. mine too. :) From jerlbeck at sysmocom.de Thu Sep 12 08:42:55 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 12 Sep 2013 10:42:55 +0200 Subject: [PATCH 2/4] vty: Hide unconfigured BTS on 'write' In-Reply-To: <20130912032359.26335.qmail@stuge.se> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> <1378889218-5195-2-git-send-email-jerlbeck@sysmocom.de> <20130912032359.26335.qmail@stuge.se> Message-ID: <52317E8F.1060500@sysmocom.de> On 09/12/2013 05:23 AM, Peter Stuge wrote: > > My personal taste is to test all required conditions and exit early > if they aren't met. > > That way, it's easy to get an overview of all conditions, before the > "meat" of the function takes place. It also avoids one level of > nesting for each condition. The patch would in this case become quite > simple: > > + if (!bts->model) > + return; > > (Maybe even if (!bts || !bts->model) ..) I agree, that's much better. Thanks for looking into it. Jacob From jerlbeck at sysmocom.de Wed Sep 11 08:46:57 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 11 Sep 2013 10:46:57 +0200 Subject: [PATCH 3/4] ctrl: Remember last 'rf_locked' control command In-Reply-To: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378889218-5195-3-git-send-email-jerlbeck@sysmocom.de> This stores the last SET rf_locked control command along with a timestamp. The 'show network' vty command is extended to show this information. Ticket: OW#659 --- openbsc/include/openbsc/osmo_bsc_rf.h | 2 ++ openbsc/src/libbsc/bsc_rf_ctrl.c | 1 + openbsc/src/libbsc/bsc_vty.c | 4 ++++ openbsc/src/osmo-bsc/osmo_bsc_ctrl.c | 18 +++++++++++++++--- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/openbsc/include/openbsc/osmo_bsc_rf.h b/openbsc/include/openbsc/osmo_bsc_rf.h index a67e1bd..19ccd08 100644 --- a/openbsc/include/openbsc/osmo_bsc_rf.h +++ b/openbsc/include/openbsc/osmo_bsc_rf.h @@ -33,6 +33,8 @@ struct osmo_bsc_rf { const char *last_state_command; + char *last_rf_lock_ctrl_command; + /* delay the command */ char last_request; struct osmo_timer_list delay_cmd; diff --git a/openbsc/src/libbsc/bsc_rf_ctrl.c b/openbsc/src/libbsc/bsc_rf_ctrl.c index bd36e18..bce91e4 100644 --- a/openbsc/src/libbsc/bsc_rf_ctrl.c +++ b/openbsc/src/libbsc/bsc_rf_ctrl.c @@ -504,6 +504,7 @@ struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net rf->gsm_network = net; rf->policy = S_RF_ON; rf->last_state_command = ""; + rf->last_rf_lock_ctrl_command = talloc_asprintf(rf, ""); /* check the rf state */ rf->rf_check.data = rf; diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 55564b6..3fb8516 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -210,6 +210,10 @@ static void net_dump_vty(struct vty *vty, struct gsm_network *net) vty_out(vty, " Last RF Command: %s%s", net->bsc_data->rf_ctrl->last_state_command, VTY_NEWLINE); + if (net->bsc_data && net->bsc_data->rf_ctrl) + vty_out(vty, " Last RF Lock Command: %s%s", + net->bsc_data->rf_ctrl->last_rf_lock_ctrl_command, + VTY_NEWLINE); } DEFUN(show_net, show_net_cmd, "show network", diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c index 72abcf4..4e104db 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c @@ -35,6 +35,8 @@ #include #include +#define TIME_FORMAT_RFC2822 "%a, %d %b %Y %T %z" + void osmo_bsc_send_trap(struct ctrl_cmd *cmd, struct bsc_msc_connection *msc_con) { struct ctrl_cmd *trap; @@ -420,18 +422,28 @@ static int set_net_rf_lock(struct ctrl_cmd *cmd, void *data) { int locked = atoi(cmd->value); struct gsm_network *net = cmd->node; + time_t now = time(NULL); + char now_buf[64]; + struct osmo_bsc_rf *rf; + if (!net) { cmd->reply = "net not found."; return CTRL_CMD_ERROR; } - if (!net->bsc_data->rf_ctrl) { + rf = net->bsc_data->rf_ctrl; + + if (!rf) { cmd->reply = "RF Ctrl is not enabled in the BSC Configuration"; return CTRL_CMD_ERROR; } - osmo_bsc_rf_schedule_lock(net->bsc_data->rf_ctrl, - locked == 1 ? '0' : '1'); + talloc_free(rf->last_rf_lock_ctrl_command); + strftime(now_buf, sizeof(now_buf), TIME_FORMAT_RFC2822, gmtime(&now)); + rf->last_rf_lock_ctrl_command = + talloc_asprintf(rf, "rf_locked %u (%s)", locked, now_buf); + + osmo_bsc_rf_schedule_lock(rf, locked == 1 ? '0' : '1'); cmd->reply = talloc_asprintf(cmd, "%u", locked); if (!cmd->reply) { -- 1.7.9.5 From holger at freyther.de Wed Sep 11 18:24:30 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 11 Sep 2013 20:24:30 +0200 Subject: [PATCH 3/4] ctrl: Remember last 'rf_locked' control command In-Reply-To: <1378889218-5195-3-git-send-email-jerlbeck@sysmocom.de> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> <1378889218-5195-3-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130911182430.GB4733@xiaoyu.lan> On Wed, Sep 11, 2013 at 10:46:57AM +0200, Jacob Erlbeck wrote: > + rf->last_rf_lock_ctrl_command = talloc_asprintf(rf, ""); GCC warns about this: bsc_rf_ctrl.c: In function ?osmo_bsc_rf_create?: bsc_rf_ctrl.c:507:2: warning: zero-length gnu_printf format string [-Wformat-zero-length] the alternative is a strdup. I have modified it. From jerlbeck at sysmocom.de Wed Sep 11 08:46:58 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 11 Sep 2013 10:46:58 +0200 Subject: [PATCH 4/4] ctrl: Fix generic reply when verification fails In-Reply-To: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1378889218-5195-4-git-send-email-jerlbeck@sysmocom.de> When verification failed and the reply string was not updated, the message "Someone forgot to fill in the reply." was shown instead of the default "Value failed verification." message. This patch modifies the implementation to set the default message if and only if verification fails and the reply hasn't been changed. --- openbsc/src/libctrl/control_cmd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openbsc/src/libctrl/control_cmd.c b/openbsc/src/libctrl/control_cmd.c index 3c4efc0..4d93c75 100644 --- a/openbsc/src/libctrl/control_cmd.c +++ b/openbsc/src/libctrl/control_cmd.c @@ -135,10 +135,12 @@ int ctrl_cmd_exec(vector vline, struct ctrl_cmd *command, vector node, void *dat goto out; } if (cmd_el->verify) { + const char *old_reply = command->reply; + if ((ret = cmd_el->verify(command, command->value, data))) { ret = CTRL_CMD_ERROR; /* If verify() set an appropriate error message, don't change it. */ - if (!command->reply) + if (command->reply == old_reply) command->reply = "Value failed verification."; goto out; } -- 1.7.9.5 From holger at freyther.de Wed Sep 11 18:22:47 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 11 Sep 2013 20:22:47 +0200 Subject: [PATCH 4/4] ctrl: Fix generic reply when verification fails In-Reply-To: <1378889218-5195-4-git-send-email-jerlbeck@sysmocom.de> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> <1378889218-5195-4-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130911182247.GA4733@xiaoyu.lan> On Wed, Sep 11, 2013 at 10:46:58AM +0200, Jacob Erlbeck wrote: Daniel, > When verification failed and the reply string was not updated, the > message "Someone forgot to fill in the reply." was shown instead > of the default "Value failed verification." message. could you please comment on the patch? > This patch modifies the implementation to set the default message > if and only if verification fails and the reply hasn't been changed. > --- > openbsc/src/libctrl/control_cmd.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/openbsc/src/libctrl/control_cmd.c b/openbsc/src/libctrl/control_cmd.c > index 3c4efc0..4d93c75 100644 > --- a/openbsc/src/libctrl/control_cmd.c > +++ b/openbsc/src/libctrl/control_cmd.c > @@ -135,10 +135,12 @@ int ctrl_cmd_exec(vector vline, struct ctrl_cmd *command, vector node, void *dat > goto out; > } > if (cmd_el->verify) { > + const char *old_reply = command->reply; > + > if ((ret = cmd_el->verify(command, command->value, data))) { > ret = CTRL_CMD_ERROR; > /* If verify() set an appropriate error message, don't change it. */ > - if (!command->reply) > + if (command->reply == old_reply) > command->reply = "Value failed verification."; > goto out; > } > -- > 1.7.9.5 > > From jerlbeck at sysmocom.de Thu Sep 12 08:40:35 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 12 Sep 2013 10:40:35 +0200 Subject: [PATCH 4/4] ctrl: Fix generic reply when verification fails In-Reply-To: <20130911182247.GA4733@xiaoyu.lan> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> <1378889218-5195-4-git-send-email-jerlbeck@sysmocom.de> <20130911182247.GA4733@xiaoyu.lan> Message-ID: <52317E03.1020609@sysmocom.de> On 09/11/2013 08:22 PM, Holger Hans Peter Freyther wrote: > On Wed, Sep 11, 2013 at 10:46:58AM +0200, Jacob Erlbeck wrote: > >> When verification failed and the reply string was not updated, the >> message "Someone forgot to fill in the reply." was shown instead >> of the default "Value failed verification." message. > could you please comment on the patch? > >> This patch modifies the implementation to set the default message >> if and only if verification fails and the reply hasn't been changed. Having thought a little bit more about that, I'd rather modify ctrl_cmd_handle() to set cmd->reply at the end when it's still NULL and leave ctrl_cmd_exec() like it was: --- a/openbsc/src/libctrl/control_if.c +++ b/openbsc/src/libctrl/control_if.c @@ -147,7 +147,7 @@ int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data) vector vline, cmdvec, cmds_vec; ret = CTRL_CMD_ERROR; - cmd->reply = "Someone forgot to fill in the reply."; + cmd->reply = NULL; node = CTRL_NODE_ROOT; cmd->node = net; @@ -238,6 +238,14 @@ int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data) cmd_free_strvec(vline); err: + if (!cmd->reply) { + LOGP(DCTRL, LOGL_ERROR, "cmd->replay has not been set.\n", ret); + if (ret == CTRL_CMD_ERROR) + cmd->reply = "An error has occured."; + else + cmd->reply = "Command has been handled."; + } + if (ret == CTRL_CMD_ERROR) cmd->type = CTRL_TYPE_ERROR; return ret; >> --- >> openbsc/src/libctrl/control_cmd.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/openbsc/src/libctrl/control_cmd.c b/openbsc/src/libctrl/control_cmd.c >> index 3c4efc0..4d93c75 100644 >> --- a/openbsc/src/libctrl/control_cmd.c >> +++ b/openbsc/src/libctrl/control_cmd.c >> @@ -135,10 +135,12 @@ int ctrl_cmd_exec(vector vline, struct ctrl_cmd *command, vector node, void *dat >> goto out; >> } >> if (cmd_el->verify) { >> + const char *old_reply = command->reply; >> + >> if ((ret = cmd_el->verify(command, command->value, data))) { >> ret = CTRL_CMD_ERROR; >> /* If verify() set an appropriate error message, don't change it. */ >> - if (!command->reply) >> + if (command->reply == old_reply) >> command->reply = "Value failed verification."; >> goto out; >> } >> -- >> 1.7.9.5 >> >> From dwillmann at sysmocom.de Fri Sep 13 07:44:05 2013 From: dwillmann at sysmocom.de (Daniel Willmann) Date: Fri, 13 Sep 2013 09:44:05 +0200 Subject: [PATCH 4/4] ctrl: Fix generic reply when verification fails In-Reply-To: <52317E03.1020609@sysmocom.de> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> <1378889218-5195-4-git-send-email-jerlbeck@sysmocom.de> <20130911182247.GA4733@xiaoyu.lan> <52317E03.1020609@sysmocom.de> Message-ID: <20130913074405.GA12165@adrastea.totalueberwachung.de> Hi, On Thu, 2013-09-12 at 10:40, Jacob Erlbeck wrote: > On 09/11/2013 08:22 PM, Holger Hans Peter Freyther wrote: > > On Wed, Sep 11, 2013 at 10:46:58AM +0200, Jacob Erlbeck wrote: > > > >> When verification failed and the reply string was not updated, the > >> message "Someone forgot to fill in the reply." was shown instead > >> of the default "Value failed verification." message. > > could you please comment on the patch? > > > >> This patch modifies the implementation to set the default message > >> if and only if verification fails and the reply hasn't been changed. > Having thought a little bit more about that, I'd rather modify > ctrl_cmd_handle() > to set cmd->reply at the end when it's still NULL and leave > ctrl_cmd_exec() like > it was: this looks better, yeah. > --- a/openbsc/src/libctrl/control_if.c > +++ b/openbsc/src/libctrl/control_if.c > @@ -147,7 +147,7 @@ int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data) > vector vline, cmdvec, cmds_vec; > > ret = CTRL_CMD_ERROR; > - cmd->reply = "Someone forgot to fill in the reply."; > + cmd->reply = NULL; > node = CTRL_NODE_ROOT; > cmd->node = net; > > @@ -238,6 +238,14 @@ int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data) > cmd_free_strvec(vline); > > err: > + if (!cmd->reply) { > + LOGP(DCTRL, LOGL_ERROR, "cmd->replay has not been set.\n", ret); > + if (ret == CTRL_CMD_ERROR) > + cmd->reply = "An error has occured."; > + else > + cmd->reply = "Command has been handled."; > + } > + > if (ret == CTRL_CMD_ERROR) > cmd->type = CTRL_TYPE_ERROR; > return ret; Regards, - Daniel Willmann http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Schivelbeiner Str. 5 * 10439 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From holger at freyther.de Sun Sep 15 15:36:40 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sun, 15 Sep 2013 17:36:40 +0200 Subject: [PATCH 4/4] ctrl: Fix generic reply when verification fails In-Reply-To: <20130913074405.GA12165@adrastea.totalueberwachung.de> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> <1378889218-5195-4-git-send-email-jerlbeck@sysmocom.de> <20130911182247.GA4733@xiaoyu.lan> <52317E03.1020609@sysmocom.de> <20130913074405.GA12165@adrastea.totalueberwachung.de> Message-ID: <20130915153640.GP11068@xiaoyu.lan> On Fri, Sep 13, 2013 at 09:44:05AM +0200, Daniel Willmann wrote: > > this looks better, yeah. Dear Jacob, should I use the commit message from the first patch with the diff from your re-worked change? holger From jerlbeck at sysmocom.de Mon Sep 16 09:20:28 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 16 Sep 2013 11:20:28 +0200 Subject: [PATCH 1/2] ctrl: Add test script for the BSC control interface In-Reply-To: <1378889218-5195-4-git-send-email-jerlbeck@sysmocom.de> References: <1378889218-5195-4-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1379323229-29142-1-git-send-email-jerlbeck@sysmocom.de> This script is similar to vty_test_runner.py but tests the control interface instead. It currently tests some error cases, BTS status queries, and setting/clearing rf_locked. --- openbsc/tests/Makefile.am | 3 +- openbsc/tests/ctrl_test_runner.py | 240 +++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 openbsc/tests/ctrl_test_runner.py diff --git a/openbsc/tests/Makefile.am b/openbsc/tests/Makefile.am index 0597c14..f2dc057 100644 --- a/openbsc/tests/Makefile.am +++ b/openbsc/tests/Makefile.am @@ -27,7 +27,7 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac echo ' [$(PACKAGE_URL)])'; \ } >'$(srcdir)/package.m4' -EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) vty_test_runner.py +EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) vty_test_runner.py ctrl_test_runner.py TESTSUITE = $(srcdir)/testsuite DISTCLEANFILES = atconfig @@ -36,6 +36,7 @@ python-tests: $(BUILT_SOURCES) osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v osmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v $(PYTHON) $(srcdir)/vty_test_runner.py -w $(abs_top_builddir) -v + $(PYTHON) $(srcdir)/ctrl_test_runner.py -w $(abs_top_builddir) -v rm -f $(top_builddir)/hlr.sqlite3 else python-tests: $(BUILT_SOURCES) diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py new file mode 100644 index 0000000..8f5a0ec --- /dev/null +++ b/openbsc/tests/ctrl_test_runner.py @@ -0,0 +1,240 @@ +#!/usr/bin/env python + +# (C) 2013 by Jacob Erlbeck +# based on vty_test_runner.py: +# (C) 2013 by Katerina Barone-Adesi +# (C) 2013 by Holger Hans Peter Freyther +# based on bsc_control.py. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import time +import unittest +import socket +import sys +import struct + +import osmopy.obscvty as obscvty +import osmopy.osmoutil as osmoutil + +confpath = '.' +verbose = False + +class TestCtrlBase(unittest.TestCase): + + def ctrl_command(self): + raise Exception("Needs to be implemented by a subclass") + + def ctrl_app(self): + raise Exception("Needs to be implemented by a subclass") + + def setUp(self): + osmo_ctrl_cmd = self.ctrl_command()[:] + config_index = osmo_ctrl_cmd.index('-c') + if config_index: + cfi = config_index + 1 + osmo_ctrl_cmd[cfi] = os.path.join(confpath, osmo_ctrl_cmd[cfi]) + + try: + print "Launch: %s from %s" % (' '.join(osmo_ctrl_cmd), os.getcwd()) + self.proc = osmoutil.popen_devnull(osmo_ctrl_cmd) + except OSError: + print >> sys.stderr, "Current directory: %s" % os.getcwd() + print >> sys.stderr, "Consider setting -b" + time.sleep(2) + + appstring = self.ctrl_app()[2] + appport = self.ctrl_app()[0] + self.connect("127.0.0.1", appport) + self.next_id = 1000 + + def tearDown(self): + self.disconnect() + osmoutil.end_proc(self.proc) + + def prefix_ipa_ctrl_header(self, data): + return struct.pack(">HBB", len(data)+1, 0xee, 0) + data + + def remove_ipa_ctrl_header(self, data): + if (len(data) < 4): + raise BaseException("Answer too short!") + (plen, ipa_proto, osmo_proto) = struct.unpack(">HBB", data[:4]) + if (plen + 3 > len(data)): + print "Warning: Wrong payload length (expected %i, got %i)" % (plen, len(data) - 3) + if (ipa_proto != 0xee or osmo_proto != 0): + raise BaseException("Wrong protocol in answer!") + + return data[4:plen+3], data[plen+3:] + + def disconnect(self): + if not (self.sock is None): + self.sock.close() + + def connect(self, host, port): + if verbose: + print "Connecting to host %s:%i" % (host, port) + + sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sck.setblocking(1) + sck.connect((host, port)) + self.sock = sck + return sck + + def send(self, data): + if verbose: + print "Sending \"%s\"" %(data) + data = self.prefix_ipa_ctrl_header(data) + return self.sock.send(data) == len(data) + + def send_set(self, var, value, id): + setmsg = "SET %s %s %s" %(id, var, value) + return self.send(setmsg) + + def send_get(self, var, id): + getmsg = "GET %s %s" %(id, var) + return self.send(getmsg) + + def do_set(self, var, value): + id = self.next_id + self.next_id += 1 + self.send_set(var, value, id) + return self.recv_msgs()[id] + + def do_get(self, var): + id = self.next_id + self.next_id += 1 + self.send_get(var, id) + return self.recv_msgs()[id] + + def recv_msgs(self): + responses = {} + data = self.sock.recv(4096) + while (len(data)>0): + (answer, data) = self.remove_ipa_ctrl_header(data) + if verbose: + print "Got message:", answer + (mtype, id, msg) = answer.split(None, 2) + id = int(id) + rsp = {'mtype': mtype, 'id': id} + if mtype == "ERROR": + rsp['error'] = msg + else: + [rsp['var'], rsp['value']] = msg.split(None, 2) + + responses[id] = rsp + + if verbose: + print "Decoded replies: ", responses + + return responses + + +class TestCtrlBSC(TestCtrlBase): + + def tearDown(self): + TestCtrlBase.tearDown(self) + os.unlink("tmp_dummy_sock") + + def ctrl_command(self): + return ["./src/osmo-bsc/osmo-bsc", "-r", "tmp_dummy_sock", "-c", + "doc/examples/osmo-bsc/osmo-bsc.cfg"] + + def ctrl_app(self): + return (4249, "./src/osmo-bsc/osmo-bsc", "OsmoBSC", "bsc") + + def testCtrlErrs(self): + r = self.do_get('invalid') + self.assertEquals(r['mtype'], 'ERROR') + self.assertEquals(r['error'], 'Command not found') + + r = self.do_get('bts') + self.assertEquals(r['mtype'], 'ERROR') + self.assertEquals(r['error'], 'Error while parsing the index.') + + r = self.do_get('bts.999') + self.assertEquals(r['mtype'], 'ERROR') + self.assertEquals(r['error'], 'Error while resolving object') + + def testRfLock(self): + r = self.do_get('bts.0.rf_state') + self.assertEquals(r['mtype'], 'GET_REPLY') + self.assertEquals(r['var'], 'bts.0.rf_state') + self.assertEquals(r['value'], 'inoperational,unlocked,on') + + r = self.do_set('rf_locked', '1') + self.assertEquals(r['mtype'], 'SET_REPLY') + self.assertEquals(r['var'], 'rf_locked') + self.assertEquals(r['value'], '1') + + time.sleep(1.5) + + r = self.do_get('bts.0.rf_state') + self.assertEquals(r['mtype'], 'GET_REPLY') + self.assertEquals(r['var'], 'bts.0.rf_state') + self.assertEquals(r['value'], 'inoperational,locked,off') + + r = self.do_set('rf_locked', '0') + self.assertEquals(r['mtype'], 'SET_REPLY') + self.assertEquals(r['var'], 'rf_locked') + self.assertEquals(r['value'], '0') + + time.sleep(1.5) + + r = self.do_get('bts.0.rf_state') + self.assertEquals(r['mtype'], 'GET_REPLY') + self.assertEquals(r['var'], 'bts.0.rf_state') + self.assertEquals(r['value'], 'inoperational,unlocked,on') + +def add_bsc_test(suite, workdir): + if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc/osmo-bsc")): + print("Skipping the BSC test") + return + test = unittest.TestLoader().loadTestsFromTestCase(TestCtrlBSC) + suite.addTest(test) + +if __name__ == '__main__': + import argparse + import sys + + workdir = '.' + + parser = argparse.ArgumentParser() + parser.add_argument("-v", "--verbose", dest="verbose", + action="store_true", help="verbose mode") + parser.add_argument("-p", "--pythonconfpath", dest="p", + help="searchpath for config") + parser.add_argument("-w", "--workdir", dest="w", + help="Working directory") + args = parser.parse_args() + + verbose_level = 1 + if args.verbose: + verbose_level = 2 + verbose = True + + if args.w: + workdir = args.w + + if args.p: + confpath = args.p + + print "confpath %s, workdir %s" % (confpath, workdir) + os.chdir(workdir) + print "Running tests for specific control commands" + suite = unittest.TestSuite() + add_bsc_test(suite, workdir) + res = unittest.TextTestRunner(verbosity=verbose_level).run(suite) + sys.exit(len(res.errors) + len(res.failures)) + -- 1.7.9.5 From jerlbeck at sysmocom.de Mon Sep 16 09:20:29 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 16 Sep 2013 11:20:29 +0200 Subject: [PATCH 2/2] ctrl: Set a generic reply when it hasn'n been set In-Reply-To: <1379323229-29142-1-git-send-email-jerlbeck@sysmocom.de> References: <1378889218-5195-4-git-send-email-jerlbeck@sysmocom.de> <1379323229-29142-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1379323229-29142-2-git-send-email-jerlbeck@sysmocom.de> When verification failed and the reply string was not updated, the message "Someone forgot to fill in the reply." was shown instead of the default "Value failed verification." message. This patch changes the default reply handling in ctrl_cmd_handle() by setting the reply to NULL initially and then checking it at the end. If it hasn't been set, a generic message is assigned and an error is logged. --- openbsc/src/libctrl/control_if.c | 10 +++++++++- openbsc/tests/ctrl_test_runner.py | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c index b31f34f..2076f0c 100644 --- a/openbsc/src/libctrl/control_if.c +++ b/openbsc/src/libctrl/control_if.c @@ -147,7 +147,7 @@ int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data) vector vline, cmdvec, cmds_vec; ret = CTRL_CMD_ERROR; - cmd->reply = "Someone forgot to fill in the reply."; + cmd->reply = NULL; node = CTRL_NODE_ROOT; cmd->node = net; @@ -238,6 +238,14 @@ int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data) cmd_free_strvec(vline); err: + if (!cmd->reply) { + LOGP(DCTRL, LOGL_ERROR, "cmd->replay has not been set.\n", ret); + if (ret == CTRL_CMD_ERROR) + cmd->reply = "An error has occured."; + else + cmd->reply = "Command has been handled."; + } + if (ret == CTRL_CMD_ERROR) cmd->type = CTRL_TYPE_ERROR; return ret; diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py index 8f5a0ec..b012981 100644 --- a/openbsc/tests/ctrl_test_runner.py +++ b/openbsc/tests/ctrl_test_runner.py @@ -159,6 +159,10 @@ class TestCtrlBSC(TestCtrlBase): self.assertEquals(r['mtype'], 'ERROR') self.assertEquals(r['error'], 'Command not found') + r = self.do_set('rf_locked', '999') + self.assertEquals(r['mtype'], 'ERROR') + self.assertEquals(r['error'], 'Value failed verification.') + r = self.do_get('bts') self.assertEquals(r['mtype'], 'ERROR') self.assertEquals(r['error'], 'Error while parsing the index.') -- 1.7.9.5 From holger at freyther.de Wed Sep 11 18:06:17 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 11 Sep 2013 20:06:17 +0200 Subject: [PATCH 1/4] ussd: Send USSD on call setup on MSC errors In-Reply-To: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> References: <1378889218-5195-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130911180617.GB20008@xiaoyu.lan> On Wed, Sep 11, 2013 at 10:46:55AM +0200, Jacob Erlbeck wrote: Good Evening, these patches look fine! The only things I have is coding style. I understand that it takes some time to get used to it. > + if (! text) no space > + if (! msg || msgb_l3len(msg) < sizeof(*gh)) { > + return; > + } nu curly braces for single instructions, no space > + bsc_send_ussd_notification(conn, msg, conn->bts->network->bsc_data->ussd_no_msc_txt); Maybe we should start to save the bsc_data in the subscriber connection as well? > + if (ret != BSC_CON_SUCCESS) { > + /* allocation has failed */ > + if (ret == BSC_CON_REJECT_NO_LINK) { > + bsc_send_ussd_notification(conn, msg, msc->ussd_msc_lost_txt); > + } else if (ret == BSC_CON_REJECT_RF_GRACE) { > + bsc_send_ussd_notification(conn, msg, msc->ussd_grace_txt); > + } no curly braces. > + if (!msc || !msc->msc_con->is_authenticated) { > + // VSAT link down left over of debug changes/information leak. I will try to fix these warnings right now. You will not need to send another round of patches. From Ivan.Kluchnikov at fairwaves.ru Wed Sep 11 14:57:44 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Wed, 11 Sep 2013 18:57:44 +0400 Subject: [PATCH] Added new auth policy black-list. Message-ID: In this mode by default we set authorized = 1 for all new subscribers. BSC accepts all MS, except subscribers not authorized in DB. All subscribers with authorized = 0 are part of the black list and not accepted. --- openbsc/include/openbsc/gsm_data.h | 1 + openbsc/src/libbsc/bsc_vty.c | 5 +++-- openbsc/src/libcommon/gsm_data.c | 1 + openbsc/src/libmsc/db.c | 12 +++++++++--- openbsc/src/libmsc/gsm_04_08.c | 2 ++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 8741505..99e9b27 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -194,6 +194,7 @@ enum gsm_auth_policy { GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */ GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */ GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */ + GSM_AUTH_POLICY_BLACK_LIST /* accept everyone, except subscribers not authorized in DB */ }; #define GSM_T3101_DEFAULT 10 diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 5748945..7a89ca6 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -1186,12 +1186,13 @@ DEFUN(cfg_net_name_long, DEFUN(cfg_net_auth_policy, cfg_net_auth_policy_cmd, - "auth policy (closed|accept-all|token)", + "auth policy (closed|accept-all|token|black-list)", "Authentication (not cryptographic)\n" "Set the GSM network authentication policy\n" "Require the MS to be activated in HLR\n" "Accept all MS, whether in HLR or not\n" - "Use SMS-token based authentication\n") + "Use SMS-token based authentication\n" + "Accept all MS, except not authorized in HLR\n") { enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]); struct gsm_network *gsmnet = gsmnet_from_vty(vty); diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c index 5f7e32e..31b65ee 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -256,6 +256,7 @@ static const struct value_string auth_policy_names[] = { { GSM_AUTH_POLICY_CLOSED, "closed" }, { GSM_AUTH_POLICY_ACCEPT_ALL, "accept-all" }, { GSM_AUTH_POLICY_TOKEN, "token" }, + { GSM_AUTH_POLICY_BLACK_LIST, "black-list"}, { 0, NULL } }; diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 21abce9..440509a 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -319,6 +319,7 @@ struct gsm_subscriber *db_create_subscriber(struct gsm_network *net, char *imsi) { dbi_result result; struct gsm_subscriber *subscr; + int authorized = 0; /* Is this subscriber known in the db? */ subscr = db_get_subscriber(net, GSM_SUBSCRIBER_IMSI, imsi); @@ -337,17 +338,22 @@ struct gsm_subscriber *db_create_subscriber(struct gsm_network *net, char *imsi) if (!subscr) return NULL; subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + + if (net->auth_policy == GSM_AUTH_POLICY_BLACK_LIST) + authorized = 1; + result = dbi_conn_queryf(conn, "INSERT INTO Subscriber " - "(imsi, created, updated) " + "(imsi, created, updated, authorized) " "VALUES " - "(%s, datetime('now'), datetime('now')) ", - imsi + "(%s, datetime('now'), datetime('now'), %d) ", + imsi, authorized ); if (!result) LOGP(DDB, LOGL_ERROR, "Failed to create Subscriber by IMSI.\n"); subscr->net = net; subscr->id = dbi_conn_sequence_last(conn, NULL); + subscr->authorized = authorized; strncpy(subscr->imsi, imsi, GSM_IMSI_LENGTH-1); dbi_result_free(result); LOGP(DDB, LOGL_INFO, "New Subscriber: ID %llu, IMSI %s\n", subscr->id, subscr->imsi); diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index d81dab9..8f8eaa9 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -241,6 +241,8 @@ static int authorize_subscriber(struct gsm_loc_updating_operation *loc, return (subscriber->flags & GSM_SUBSCRIBER_FIRST_CONTACT); case GSM_AUTH_POLICY_ACCEPT_ALL: return 1; + case GSM_AUTH_POLICY_BLACK_LIST: + return subscriber->authorized; default: return 0; } -- 1.7.9.5 -- Regards, Ivan Kluchnikov. http://fairwaves.ru From holger at freyther.de Wed Sep 11 17:55:22 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 11 Sep 2013 19:55:22 +0200 Subject: [PATCH] Added new auth policy black-list. In-Reply-To: References: Message-ID: <20130911175522.GA20008@xiaoyu.lan> On Wed, Sep 11, 2013 at 06:57:44PM +0400, Ivan Kluchnikov wrote: Dear Ivan, do you intend to finish the ACC patch? I would like to have this finished before starting to review any other fairwaves code. holger From alexander.chemeris at gmail.com Thu Sep 12 07:34:54 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Thu, 12 Sep 2013 11:34:54 +0400 Subject: [PATCH] Added new auth policy black-list. In-Reply-To: <20130911175522.GA20008@xiaoyu.lan> References: <20130911175522.GA20008@xiaoyu.lan> Message-ID: Holger, On Wed, Sep 11, 2013 at 9:55 PM, Holger Hans Peter Freyther wrote: > On Wed, Sep 11, 2013 at 06:57:44PM +0400, Ivan Kluchnikov wrote: > > Dear Ivan, > > do you intend to finish the ACC patch? I would like to have this > finished before starting to review any other fairwaves code. We intend to finish the ACC patch, but it's of lower priority for us (just like the SMPP DB patch for you). I would appreciate if you review patches on their own merits. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From holger at freyther.de Thu Sep 12 08:26:43 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 12 Sep 2013 10:26:43 +0200 Subject: [PATCH] Added new auth policy black-list. In-Reply-To: References: <20130911175522.GA20008@xiaoyu.lan> Message-ID: <20130912082643.GB22410@xiaoyu.lan> On Thu, Sep 12, 2013 at 11:34:54AM +0400, Alexander Chemeris wrote: > We intend to finish the ACC patch, but it's of lower priority for us > (just like the SMPP DB patch for you). I would appreciate if you > review patches on their own merits. Dear Alexander, it is not a question of priority. When I review a patch and I find issues (like with the ACC patch, or the nanoBTS init code), I expect to get a follow up patch within reasonable time. In the past this has not happened, or worse, there was an open refusal to increase the quality of the contribution. Please sent follow-up patches in a reasonable time and I will review and merge your changes quickly. holger PS: For this patch the comment is like the ACC patch. Create a VTY unit test that verifies that one can set/unset the policy. Jacob has posted plenty of examples recently. From alexander.chemeris at gmail.com Thu Sep 12 09:12:43 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Thu, 12 Sep 2013 13:12:43 +0400 Subject: [PATCH] Added new auth policy black-list. In-Reply-To: <20130912082643.GB22410@xiaoyu.lan> References: <20130911175522.GA20008@xiaoyu.lan> <20130912082643.GB22410@xiaoyu.lan> Message-ID: Holger, On Thu, Sep 12, 2013 at 12:26 PM, Holger Hans Peter Freyther wrote: > On Thu, Sep 12, 2013 at 11:34:54AM +0400, Alexander Chemeris wrote: > >> We intend to finish the ACC patch, but it's of lower priority for us >> (just like the SMPP DB patch for you). I would appreciate if you >> review patches on their own merits. > > Dear Alexander, > > it is not a question of priority. When I review a patch and I find > issues (like with the ACC patch, or the nanoBTS init code), I > expect to get a follow up patch within reasonable time. > In the past this has not happened, or worse, there was an open > refusal to increase the quality of the contribution. > > Please sent follow-up patches in a reasonable time and I will review > and merge your changes quickly. We're trying to improve our patches in a reasonable time. But "reasonable time" depends on our priorities and when we could find the time to fix things. If the amount of effort is more than the value of the patch, it'll take a lot of time before the get to fixing it. I hope you understand that. Regarding the nanoBTS init code, I explicitly stated, that this is a hack which I found useful for myself and want to share with the community. I'm glad if it helps someone, but I don't care if it's included into master or not. OTOH, black list, SMPP DB and ACC patches are ones which we actually use in one or another case, and thus we would appreciate to see them in master. > PS: For this patch the comment is like the ACC patch. Create a VTY > unit test that verifies that one can set/unset the policy. Jacob > has posted plenty of examples recently. Thanks for the comment we'll look into that. PS It would be very helpful if you put together a (short) list of things to check before submitting a patch for inclusion to the master. It'll save a lot of time and nerves for everyone. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From alexander.chemeris at gmail.com Thu Sep 12 10:06:32 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Thu, 12 Sep 2013 14:06:32 +0400 Subject: Mixed TCH/F and TCH/H issues Message-ID: Hi Andreas, We were testing TCH/H yesterday and stumbled upon an issue when a call is made between TCH/F and TCH/H. - When the call is from TCH/F to TCH/H, it doesn't connect. - When the call is from TCH/H to TCH/F, it connects, but voice quality is bad - sounds like 50% packet loss. Logs and localhost Wireshark captures of calls in both directions are here: http://ipse.chemeris.ru/osmo-captures/dumps.tar.xz Do you see what's wrong with them? Our configuration was * Dual-TRX with 1 TCH/F and 14 TCH/H channels. We have to keep some TCH/F channels, since there are old phones which doesn't support TCH/H. * Codecs enabled were FR, AFS and AHS. * LCR was connected to the MNCC socket, but in the case of TCH/F->TCH/H call I didn't see it coming to LCR at all. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From andreas at eversberg.eu Mon Sep 16 13:27:25 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Mon, 16 Sep 2013 15:27:25 +0200 Subject: Mixed TCH/F and TCH/H issues In-Reply-To: References: Message-ID: <5237073D.70409@eversberg.eu> Alexander Chemeris wrote: > * LCR was connected to the MNCC socket, but in the case of > TCH/F->TCH/H call I didn't see it coming to LCR at all. > > hi alexander, the case you described is a bit weird. as long as you use the "-m" option of openbsc, you will get the mncc socket to be connected (as your logs show). then every call setup is routed to LCR. i cannot see a problem, since there are so many calls. it would help, if you start all applications, then do one call (which does not connect) and get a set of logs. regards, andreas p.s. sorry for the late reply.... From alexander.chemeris at gmail.com Tue Sep 17 06:44:35 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Tue, 17 Sep 2013 10:44:35 +0400 Subject: Mixed TCH/F and TCH/H issues In-Reply-To: <5237073D.70409@eversberg.eu> References: <5237073D.70409@eversberg.eu> Message-ID: Hi Andreas, On Mon, Sep 16, 2013 at 5:27 PM, Andreas Eversberg wrote: > Alexander Chemeris wrote: >> * LCR was connected to the MNCC socket, but in the case of >> TCH/F->TCH/H call I didn't see it coming to LCR at all. > > the case you described is a bit weird. as long as you use the "-m" > option of openbsc, you will get the mncc socket to be connected (as your > logs show). then every call setup is routed to LCR. > > i cannot see a problem, since there are so many calls. it would help, if > you start all applications, then do one call (which does not connect) > and get a set of logs. Wireshark logs in the archive have only two calls (one in each direction). You should be able to relate them to logs, correlating Wireshark timestamps and timestamps in logs. You could enable absolute time display in Wireshark for that purpose. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From andreas at eversberg.eu Tue Sep 17 12:02:13 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Tue, 17 Sep 2013 14:02:13 +0200 Subject: Mixed TCH/F and TCH/H issues In-Reply-To: References: <5237073D.70409@eversberg.eu> Message-ID: <523844C5.1050707@eversberg.eu> Alexander Chemeris wrote: > On Mon, Sep 16, 2013 at 5:27 PM, Andreas Eversberg wrote: > >> > Alexander Chemeris wrote: >> >>> >> * LCR was connected to the MNCC socket, but in the case of >>> >> TCH/F->TCH/H call I didn't see it coming to LCR at all. >>> >> > >> > the case you described is a bit weird. as long as you use the "-m" >> > option of openbsc, you will get the mncc socket to be connected (as your >> > logs show). then every call setup is routed to LCR. >> > >> > i cannot see a problem, since there are so many calls. it would help, if >> > you start all applications, then do one call (which does not connect) >> > and get a set of logs. >> > Wireshark logs in the archive have only two calls (one in each > direction). You should be able to relate them to logs, correlating > Wireshark timestamps and timestamps in logs. You could enable absolute > time display in Wireshark for that purpose. > i can see both calls. the first call "FR_to_HR-not_working.pcap": the MO phone requests a channel with the request reference that TCH/H is also supported. the openbsc assigns a TCH/H channel. the BSC find out that the phone supports only half rate V1 codec on the connection timed out after service request. the second call "HR_to_FR-working-bad_audio.pcap": the MO phone requests a channel with the request reference that TCH/H is also supported. the openbsc assigns a TCH/H channel. the MT phone gets paged with the information that TCH/F shall be used. the MT phone requests a channel with the request reference that TCH/H is also supported, but was paged with TCH/F only. the openbsc assigns a TCH/F channel. here are the problems: the first call timed out, but i really don't the setup message. i suggest to retry that call. maybe it was an issue cause by radio interference (low MS power or high power, but too close to the bts). the audio of the second call is bad, so do you use rtpbridge feature of lcr? if so, how are the amr codecs define in openbsc.conf? be sure that they are equal for AFS and AHS, since a bridge does not transcode. also there is a general problem: the TCH/F is assigned for all MT calls from LCR->BSC. there are cases where we don't know the phone's codec support, unless we assign a channel and get setup information about supported codecs. but we cannot get setup message before assigning a channel. to solve this, late assignment is used. i suggest to use the jolly/new_handover branch. (you also need handover branch of lcr.) even with handover function disabled, it will do late assignment after codec negotiation. From alexander.chemeris at gmail.com Sat Sep 21 06:02:28 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Sat, 21 Sep 2013 10:02:28 +0400 Subject: Mixed TCH/F and TCH/H issues In-Reply-To: <523844C5.1050707@eversberg.eu> References: <5237073D.70409@eversberg.eu> <523844C5.1050707@eversberg.eu> Message-ID: On Tue, Sep 17, 2013 at 4:02 PM, Andreas Eversberg wrote: > the first call timed out, but i really don't the setup message. i > suggest to retry that call. maybe it was an issue cause by radio > interference (low MS power or high power, but too close to the bts). Radio is fine and the issue was 100% reproducible. > the audio of the second call is bad, so do you use rtpbridge feature of > lcr? if so, how are the amr codecs define in openbsc.conf? be sure that > they are equal for AFS and AHS, since a bridge does not transcode. Rtpbridge was off. Codecs where set to "fr afs ahs", since we don't want to cut off phones without AMR support. > also there is a general problem: the TCH/F is assigned for all MT calls > from LCR->BSC. there are cases where we don't know the phone's codec > support, unless we assign a channel and get setup information about > supported codecs. but we cannot get setup message before assigning a > channel. to solve this, late assignment is used. i suggest to use the > jolly/new_handover branch. (you also need handover branch of lcr.) even > with handover function disabled, it will do late assignment after codec > negotiation. We could try that, but I think the issue is elsewhere, as everything works in single-trx mode. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From andreas at eversberg.eu Sat Sep 21 14:39:27 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Sat, 21 Sep 2013 16:39:27 +0200 Subject: Mixed TCH/F and TCH/H issues In-Reply-To: References: <5237073D.70409@eversberg.eu> <523844C5.1050707@eversberg.eu> Message-ID: <523DAF9F.5060805@eversberg.eu> Alexander Chemeris wrote: > We could try that, but I think the issue is elsewhere, as everything > works in single-trx mode. dual-trx seems to be the issue. i would like to try that out. the problem is that i have two umtrx, one has bad reception, but dual trx work (the first one you sent me), the second umtrx works good, but there is no rx/tx on second trx (second transceiver keeps cold). you offered me to repair the umtrx. i would like to send back the first umtrx, so you can check it. i could also send you both umtrx for a check. can you provide shipping address? From alexander.chemeris at gmail.com Sun Sep 22 11:28:03 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Sun, 22 Sep 2013 15:28:03 +0400 Subject: Mixed TCH/F and TCH/H issues In-Reply-To: <523DAF9F.5060805@eversberg.eu> References: <5237073D.70409@eversberg.eu> <523844C5.1050707@eversberg.eu> <523DAF9F.5060805@eversberg.eu> Message-ID: On Sat, Sep 21, 2013 at 6:39 PM, Andreas Eversberg wrote: > Alexander Chemeris wrote: >> >> We could try that, but I think the issue is elsewhere, as everything >> works in single-trx mode. > > dual-trx seems to be the issue. i would like to try that out. the problem is > that i have two umtrx, one has bad reception, but dual trx work (the first > one you sent me), the second umtrx works good, but there is no rx/tx on > second trx (second transceiver keeps cold). The second case is weird, since we test both channels at the fab. You're sure that you're using the latest stable firmware, latest UHD-Fairwaves and osmo-trx with "umtrx_dual_test" branch? Have you tried to check the second channel with GnuRadio or rx_samples_to_file or tx_waveforms console utils? If this doesn't work - send it to us for repair. May be something was damaged during transportation. > you offered me to repair the umtrx. i would like to send back the first > umtrx, so you can check it. i could also send you both umtrx for a check. > can you provide shipping address? I will send in a separate e-mail. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From Ivan.Kluchnikov at fairwaves.ru Fri Sep 13 10:57:25 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Fri, 13 Sep 2013 14:57:25 +0400 Subject: [PATCH 1/4] Added new auth policy black-list. Message-ID: In this mode by default we set authorized = 1 for all new subscribers. BSC accepts all MS, except subscribers not authorized in DB. All subscribers with authorized = 0 are part of the black list and not accepted. --- openbsc/include/openbsc/gsm_data.h | 1 + openbsc/src/libbsc/bsc_vty.c | 5 +++-- openbsc/src/libcommon/gsm_data.c | 1 + openbsc/src/libmsc/db.c | 12 +++++++++--- openbsc/src/libmsc/gsm_04_08.c | 2 ++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 8741505..99e9b27 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -194,6 +194,7 @@ enum gsm_auth_policy { GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */ GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */ GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */ + GSM_AUTH_POLICY_BLACK_LIST /* accept everyone, except subscribers not authorized in DB */ }; #define GSM_T3101_DEFAULT 10 diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 5748945..7a89ca6 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -1186,12 +1186,13 @@ DEFUN(cfg_net_name_long, DEFUN(cfg_net_auth_policy, cfg_net_auth_policy_cmd, - "auth policy (closed|accept-all|token)", + "auth policy (closed|accept-all|token|black-list)", "Authentication (not cryptographic)\n" "Set the GSM network authentication policy\n" "Require the MS to be activated in HLR\n" "Accept all MS, whether in HLR or not\n" - "Use SMS-token based authentication\n") + "Use SMS-token based authentication\n" + "Accept all MS, except not authorized in HLR\n") { enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]); struct gsm_network *gsmnet = gsmnet_from_vty(vty); diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c index 5f7e32e..31b65ee 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -256,6 +256,7 @@ static const struct value_string auth_policy_names[] = { { GSM_AUTH_POLICY_CLOSED, "closed" }, { GSM_AUTH_POLICY_ACCEPT_ALL, "accept-all" }, { GSM_AUTH_POLICY_TOKEN, "token" }, + { GSM_AUTH_POLICY_BLACK_LIST, "black-list"}, { 0, NULL } }; diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 21abce9..440509a 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -319,6 +319,7 @@ struct gsm_subscriber *db_create_subscriber(struct gsm_network *net, char *imsi) { dbi_result result; struct gsm_subscriber *subscr; + int authorized = 0; /* Is this subscriber known in the db? */ subscr = db_get_subscriber(net, GSM_SUBSCRIBER_IMSI, imsi); @@ -337,17 +338,22 @@ struct gsm_subscriber *db_create_subscriber(struct gsm_network *net, char *imsi) if (!subscr) return NULL; subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + + if (net->auth_policy == GSM_AUTH_POLICY_BLACK_LIST) + authorized = 1; + result = dbi_conn_queryf(conn, "INSERT INTO Subscriber " - "(imsi, created, updated) " + "(imsi, created, updated, authorized) " "VALUES " - "(%s, datetime('now'), datetime('now')) ", - imsi + "(%s, datetime('now'), datetime('now'), %d) ", + imsi, authorized ); if (!result) LOGP(DDB, LOGL_ERROR, "Failed to create Subscriber by IMSI.\n"); subscr->net = net; subscr->id = dbi_conn_sequence_last(conn, NULL); + subscr->authorized = authorized; strncpy(subscr->imsi, imsi, GSM_IMSI_LENGTH-1); dbi_result_free(result); LOGP(DDB, LOGL_INFO, "New Subscriber: ID %llu, IMSI %s\n", subscr->id, subscr->imsi); diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index d81dab9..8f8eaa9 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -241,6 +241,8 @@ static int authorize_subscriber(struct gsm_loc_updating_operation *loc, return (subscriber->flags & GSM_SUBSCRIBER_FIRST_CONTACT); case GSM_AUTH_POLICY_ACCEPT_ALL: return 1; + case GSM_AUTH_POLICY_BLACK_LIST: + return subscriber->authorized; default: return 0; } -- 1.7.9.5 -- Regards, Ivan Kluchnikov. http://fairwaves.ru From holger at freyther.de Sun Sep 15 15:34:54 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sun, 15 Sep 2013 17:34:54 +0200 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: References: Message-ID: <20130915153454.GO11068@xiaoyu.lan> On Fri, Sep 13, 2013 at 02:57:25PM +0400, Ivan Kluchnikov wrote: Dear Ivan, > diff --git a/openbsc/include/openbsc/gsm_data.h > b/openbsc/include/openbsc/gsm_data.h > @@ -319,6 +319,7 @@ struct gsm_subscriber *db_create_subscriber(struct > gsm_network *net, char *imsi) your mailer wrapped these lines and the patch is corrupt. Please re-send without line wrapping and maybe consider to set-up git send-email. The man page of git-format-patch has MUA-Specific hints for the wrapping problem. thanks holger From alexander.chemeris at gmail.com Sun Sep 15 15:57:24 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Sun, 15 Sep 2013 19:57:24 +0400 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: <20130915153454.GO11068@xiaoyu.lan> References: <20130915153454.GO11068@xiaoyu.lan> Message-ID: On Sun, Sep 15, 2013 at 7:34 PM, Holger Hans Peter Freyther wrote: > On Fri, Sep 13, 2013 at 02:57:25PM +0400, Ivan Kluchnikov wrote: > > Dear Ivan, > > >> diff --git a/openbsc/include/openbsc/gsm_data.h >> b/openbsc/include/openbsc/gsm_data.h > >> @@ -319,6 +319,7 @@ struct gsm_subscriber *db_create_subscriber(struct >> gsm_network *net, char *imsi) > > your mailer wrapped these lines and the patch is corrupt. Please > re-send without line wrapping and maybe consider to set-up git > send-email. The man page of git-format-patch has MUA-Specific > hints for the wrapping problem. Just wondering - why not cherry-pick the patch from the relevant branch in the repo? Seems to me to be much easier than working with patches from the mailing list. Would be interesting to look into your workflow, may be I'm missing something what I could use myself :) -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From holger at freyther.de Sun Sep 15 16:41:19 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sun, 15 Sep 2013 18:41:19 +0200 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: References: <20130915153454.GO11068@xiaoyu.lan> Message-ID: <20130915164119.GA5796@xiaoyu.lan> On Sun, Sep 15, 2013 at 07:57:24PM +0400, Alexander Chemeris wrote: > Just wondering - why not cherry-pick the patch from the relevant > branch in the repo? Seems to me to be much easier than working with > patches from the mailing list. Would be interesting to look into your > workflow, may be I'm missing something what I could use myself :) I reviewed the patch sent and not the branch and I prefer to use the code that I have actually reviewed instead of trying to figure out if there is a difference between patch and branch. ;) And I think it is a good thing to sort out git send-email. holger From Ivan.Kluchnikov at fairwaves.ru Mon Sep 16 09:21:43 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Mon, 16 Sep 2013 13:21:43 +0400 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: <20130915164119.GA5796@xiaoyu.lan> References: <20130915153454.GO11068@xiaoyu.lan> <20130915164119.GA5796@xiaoyu.lan> Message-ID: Hi Holger, I set up git send-email and send patches, I think now they should be ok. 2013/9/15 Holger Hans Peter Freyther : > On Sun, Sep 15, 2013 at 07:57:24PM +0400, Alexander Chemeris wrote: > >> Just wondering - why not cherry-pick the patch from the relevant >> branch in the repo? Seems to me to be much easier than working with >> patches from the mailing list. Would be interesting to look into your >> workflow, may be I'm missing something what I could use myself :) > > I reviewed the patch sent and not the branch and I prefer to use the > code that I have actually reviewed instead of trying to figure out if > there is a difference between patch and branch. ;) > > And I think it is a good thing to sort out git send-email. > > holger -- Regards, Ivan Kluchnikov. http://fairwaves.ru From peter at stuge.se Mon Sep 16 09:52:44 2013 From: peter at stuge.se (Peter Stuge) Date: Mon, 16 Sep 2013 11:52:44 +0200 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: References: <20130915153454.GO11068@xiaoyu.lan> <20130915164119.GA5796@xiaoyu.lan> Message-ID: <20130916095244.22964.qmail@stuge.se> Ivan Kluchnikov wrote: > I set up git send-email and send patches, I think now they should be ok. What about my list/range parsing that Alex wrote you would use? //Peter From Ivan.Kluchnikov at fairwaves.ru Mon Sep 16 10:59:31 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Mon, 16 Sep 2013 14:59:31 +0400 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: <20130916095244.22964.qmail@stuge.se> References: <20130915153454.GO11068@xiaoyu.lan> <20130915164119.GA5796@xiaoyu.lan> <20130916095244.22964.qmail@stuge.se> Message-ID: Hi Peter, I looked through your patch and the next step is to integrate it in libosmocore, but unfortunately now I have no time to do this. thank you for effort! 2013/9/16 Peter Stuge : > Ivan Kluchnikov wrote: >> I set up git send-email and send patches, I think now they should be ok. > > What about my list/range parsing that Alex wrote you would use? > > > //Peter > -- Regards, Ivan Kluchnikov. http://fairwaves.ru From peter at stuge.se Mon Sep 16 11:11:23 2013 From: peter at stuge.se (Peter Stuge) Date: Mon, 16 Sep 2013 13:11:23 +0200 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: References: <20130915153454.GO11068@xiaoyu.lan> <20130915164119.GA5796@xiaoyu.lan> <20130916095244.22964.qmail@stuge.se> Message-ID: <20130916111123.29632.qmail@stuge.se> Ivan Kluchnikov wrote: > I looked through your patch and the next step is to integrate it > in libosmocore, but unfortunately now I have no time to do this. > thank you for effort! "If you write it we'll use it" != "now I have no time to do this" You can't be serious? //Peter From alexander.chemeris at gmail.com Mon Sep 16 12:45:07 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Mon, 16 Sep 2013 16:45:07 +0400 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: <20130916111123.29632.qmail@stuge.se> References: <20130915153454.GO11068@xiaoyu.lan> <20130915164119.GA5796@xiaoyu.lan> <20130916095244.22964.qmail@stuge.se> <20130916111123.29632.qmail@stuge.se> Message-ID: On Mon, Sep 16, 2013 at 3:11 PM, Peter Stuge wrote: > Ivan Kluchnikov wrote: >> I looked through your patch and the next step is to integrate it >> in libosmocore, but unfortunately now I have no time to do this. >> thank you for effort! > > "If you write it we'll use it" != "now I have no time to do this" > > You can't be serious? Peter, there is a miscommunication here. What we meant - it would be nice to use your code, if it's integrated into the libosmocore. I apologize if this was not conveyed properly, it wasn't meant to be offensive. It's a nice feature and I don't think it's a lot of time to integrate your code, so we'll look into this when we get some time. If you could properly integrate it into the libosmocore, it would be a great help as well. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From Ivan.Kluchnikov at fairwaves.ru Fri Sep 13 10:59:15 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Fri, 13 Sep 2013 14:59:15 +0400 Subject: [PATCH 2/4] Added test for "auth policy" VTY command. Message-ID: --- openbsc/tests/vty_test_runner.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) mode change 100644 => 100755 openbsc/tests/vty_test_runner.py diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py old mode 100644 new mode 100755 index ab9670c..3594129 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -169,6 +169,42 @@ class TestVTYNITB(TestVTYGenericBSC): self.assertEquals(res.find('periodic location update 60'), -1) self.assert_(res.find('no periodic location update') > 0) + def testAuthPolicy (self): + self.vty.enable() + self.vty.command("configure terminal") + self.vty.command("network") + + # Test invalid input + self.vty.verify("auth policy", ['% Command incomplete.']) + + # Enable auth policy closed + self.vty.verify("auth policy closed", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('auth policy closed') > 0) + + # Enable auth policy accept-all + self.vty.verify("auth policy accept-all", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('auth policy accept-all') > 0) + + # Enable auth policy token + self.vty.verify("auth policy token", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('auth policy token') > 0) + + # Enable auth policy black-list + self.vty.verify("auth policy black-list", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('auth policy black-list') > 0) + class TestVTYBSC(TestVTYGenericBSC): def vty_command(self): -- 1.7.9.5 -- Regards, Ivan Kluchnikov. http://fairwaves.ru From Ivan.Kluchnikov at fairwaves.ru Fri Sep 13 11:01:04 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Fri, 13 Sep 2013 15:01:04 +0400 Subject: [PATCH 3/4] Added vty command for setting Access control classes. Message-ID: --- openbsc/src/libbsc/bsc_vty.c | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 7a89ca6..a06aa90 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -539,6 +539,14 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) vty_out(vty, " cell barred 1%s", VTY_NEWLINE); if ((bts->si_common.rach_control.t2 & 0x4) == 0) vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE); + if ((bts->si_common.rach_control.t3) != 0) + for (i = 0; i < 8; i++) + if (bts->si_common.rach_control.t3 & (0x1 << i)) + vty_out(vty, " rach access-control-class %d barred%s", i, VTY_NEWLINE); + if ((bts->si_common.rach_control.t2 & 0xfb) != 0) + for (i = 0; i < 8; i++) + if ((i != 2) && (bts->si_common.rach_control.t2 & (0x1 << i))) + vty_out(vty, " rach access-control-class %d barred%s", i+8, VTY_NEWLINE); for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) { if (bts->si_mode_static & (1 << i)) { vty_out(vty, " system-information %s mode static%s", @@ -1899,6 +1907,51 @@ DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd, return CMD_SUCCESS; } +DEFUN(cfg_bts_rach_ac_class, cfg_bts_rach_ac_class_cmd, + "rach access-control-class (0|1|2|3|4|5|6|7|8|9|11|12|13|14|15) (barred|allowed)", + RACH_STR + "Set access control class\n" + "Access control class 0\n" + "Access control class 1\n" + "Access control class 2\n" + "Access control class 3\n" + "Access control class 4\n" + "Access control class 5\n" + "Access control class 6\n" + "Access control class 7\n" + "Access control class 8\n" + "Access control class 9\n" + "Access control class 11 for PLMN use\n" + "Access control class 12 for security services\n" + "Access control class 13 for public utilities (e.g. water/gas suppliers)\n" + "Access control class 14 for emergency services\n" + "Access control class 15 for PLMN staff\n" + "barred to use access control class\n" + "allowed to use access control class\n") +{ + struct gsm_bts *bts = vty->index; + + uint8_t control_class; + uint8_t allowed = 0; + + if (strcmp(argv[1],"allowed") == 0) + allowed = 1; + + control_class = atoi(argv[0]); + if (control_class < 8) + if (allowed) + bts->si_common.rach_control.t3 &= ~(0x1 << control_class); + else + bts->si_common.rach_control.t3 |= (0x1 << control_class); + else + if (allowed) + bts->si_common.rach_control.t2 &= ~(0x1 << (control_class - 8)); + else + bts->si_common.rach_control.t2 |= (0x1 << (control_class - 8)); + + return CMD_SUCCESS; +} + DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd, "ms max power <0-40>", "MS Options\n" @@ -3066,6 +3119,7 @@ int bsc_vty_init(const struct log_info *cat) install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd); install_element(BTS_NODE, &cfg_bts_cell_barred_cmd); install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd); + install_element(BTS_NODE, &cfg_bts_rach_ac_class_cmd); install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd); install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd); install_element(BTS_NODE, &cfg_bts_no_per_loc_upd_cmd); -- 1.7.9.5 -- Regards, Ivan Kluchnikov. http://fairwaves.ru From Ivan.Kluchnikov at fairwaves.ru Fri Sep 13 11:02:14 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Fri, 13 Sep 2013 15:02:14 +0400 Subject: [PATCH 4/4] Added test for "rach access-control-class" VTY command. Message-ID: --- openbsc/tests/vty_test_runner.py | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 3594129..6f45939 100755 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -205,6 +205,89 @@ class TestVTYNITB(TestVTYGenericBSC): res = self.vty.command("write terminal") self.assert_(res.find('auth policy black-list') > 0) + def testRachAccessControlClass(self): + self.vty.enable() + self.vty.command("configure terminal") + self.vty.command("network") + self.vty.command("bts 0") + + # Test invalid input + self.vty.verify("rach access-control-class", ['% Command incomplete.']) + self.vty.verify("rach access-control-class 1", ['% Command incomplete.']) + self.vty.verify("rach access-control-class -1", ['% Unknown command.']) + self.vty.verify("rach access-control-class 10", ['% Unknown command.']) + self.vty.verify("rach access-control-class 16", ['% Unknown command.']) + + # Barred rach access control classes + self.vty.verify("rach access-control-class 0 barred", ['']) + self.vty.verify("rach access-control-class 1 barred", ['']) + self.vty.verify("rach access-control-class 2 barred", ['']) + self.vty.verify("rach access-control-class 3 barred", ['']) + self.vty.verify("rach access-control-class 4 barred", ['']) + self.vty.verify("rach access-control-class 5 barred", ['']) + self.vty.verify("rach access-control-class 6 barred", ['']) + self.vty.verify("rach access-control-class 7 barred", ['']) + self.vty.verify("rach access-control-class 8 barred", ['']) + self.vty.verify("rach access-control-class 9 barred", ['']) + self.vty.verify("rach access-control-class 11 barred", ['']) + self.vty.verify("rach access-control-class 12 barred", ['']) + self.vty.verify("rach access-control-class 13 barred", ['']) + self.vty.verify("rach access-control-class 14 barred", ['']) + self.vty.verify("rach access-control-class 15 barred", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('rach access-control-class 0 barred') > 0) + self.assert_(res.find('rach access-control-class 1 barred') > 0) + self.assert_(res.find('rach access-control-class 2 barred') > 0) + self.assert_(res.find('rach access-control-class 3 barred') > 0) + self.assert_(res.find('rach access-control-class 4 barred') > 0) + self.assert_(res.find('rach access-control-class 5 barred') > 0) + self.assert_(res.find('rach access-control-class 6 barred') > 0) + self.assert_(res.find('rach access-control-class 7 barred') > 0) + self.assert_(res.find('rach access-control-class 8 barred') > 0) + self.assert_(res.find('rach access-control-class 9 barred') > 0) + self.assert_(res.find('rach access-control-class 11 barred') > 0) + self.assert_(res.find('rach access-control-class 12 barred') > 0) + self.assert_(res.find('rach access-control-class 13 barred') > 0) + self.assert_(res.find('rach access-control-class 14 barred') > 0) + self.assert_(res.find('rach access-control-class 15 barred') > 0) + + # Allowed rach access control classes + self.vty.verify("rach access-control-class 0 allowed", ['']) + self.vty.verify("rach access-control-class 1 allowed", ['']) + self.vty.verify("rach access-control-class 2 allowed", ['']) + self.vty.verify("rach access-control-class 3 allowed", ['']) + self.vty.verify("rach access-control-class 4 allowed", ['']) + self.vty.verify("rach access-control-class 5 allowed", ['']) + self.vty.verify("rach access-control-class 6 allowed", ['']) + self.vty.verify("rach access-control-class 7 allowed", ['']) + self.vty.verify("rach access-control-class 8 allowed", ['']) + self.vty.verify("rach access-control-class 9 allowed", ['']) + self.vty.verify("rach access-control-class 11 allowed", ['']) + self.vty.verify("rach access-control-class 12 allowed", ['']) + self.vty.verify("rach access-control-class 13 allowed", ['']) + self.vty.verify("rach access-control-class 14 allowed", ['']) + self.vty.verify("rach access-control-class 15 allowed", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assertEquals(res.find('rach access-control-class 0 barred'), -1) + self.assertEquals(res.find('rach access-control-class 1 barred'), -1) + self.assertEquals(res.find('rach access-control-class 2 barred'), -1) + self.assertEquals(res.find('rach access-control-class 3 barred'), -1) + self.assertEquals(res.find('rach access-control-class 4 barred'), -1) + self.assertEquals(res.find('rach access-control-class 5 barred'), -1) + self.assertEquals(res.find('rach access-control-class 6 barred'), -1) + self.assertEquals(res.find('rach access-control-class 7 barred'), -1) + self.assertEquals(res.find('rach access-control-class 8 barred'), -1) + self.assertEquals(res.find('rach access-control-class 9 barred'), -1) + self.assertEquals(res.find('rach access-control-class 11 barred'), -1) + self.assertEquals(res.find('rach access-control-class 12 barred'), -1) + self.assertEquals(res.find('rach access-control-class 13 barred'), -1) + self.assertEquals(res.find('rach access-control-class 14 barred'), -1) + self.assertEquals(res.find('rach access-control-class 15 barred'), -1) + class TestVTYBSC(TestVTYGenericBSC): def vty_command(self): -- 1.7.9.5 -- Regards, Ivan Kluchnikov. http://fairwaves.ru From Ivan.Kluchnikov at fairwaves.ru Fri Sep 13 15:59:03 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Fri, 13 Sep 2013 19:59:03 +0400 Subject: [PATCH 4/4] Added test for "rach access-control-class" VTY command. In-Reply-To: References: Message-ID: --- openbsc/tests/vty_test_runner.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 3594129..1e25a91 100755 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -205,6 +205,41 @@ class TestVTYNITB(TestVTYGenericBSC): res = self.vty.command("write terminal") self.assert_(res.find('auth policy black-list') > 0) + def testRachAccessControlClass(self): + self.vty.enable() + self.vty.command("configure terminal") + self.vty.command("network") + self.vty.command("bts 0") + + # Test invalid input + self.vty.verify("rach access-control-class", ['% Command incomplete.']) + self.vty.verify("rach access-control-class 1", ['% Command incomplete.']) + self.vty.verify("rach access-control-class -1", ['% Unknown command.']) + self.vty.verify("rach access-control-class 10", ['% Unknown command.']) + self.vty.verify("rach access-control-class 16", ['% Unknown command.']) + + # Barred rach access control classes + for classNum in range(16): + if classNum!=10: + self.vty.verify("rach access-control-class " + str(classNum) + " barred", ['']) + + # Verify settings + res = self.vty.command("write terminal") + for classNum in range(16): + if classNum!=10: + self.assert_(res.find("rach access-control-class " + str(classNum) + " barred") > 0) + + # Allowed rach access control classes + for classNum in range(16): + if classNum!=10: + self.vty.verify("rach access-control-class " + str(classNum) + " allowed", ['']) + + # Verify settings + res = self.vty.command("write terminal") + for classNum in range(16): + if classNum!=10: + self.assertEquals(res.find("rach access-control-class " + str(classNum) + " barred"), -1) + class TestVTYBSC(TestVTYGenericBSC): def vty_command(self): -- 1.7.9.5 2013/9/13 Ivan Kluchnikov : > --- > openbsc/tests/vty_test_runner.py | 83 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 83 insertions(+) > > diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py > index 3594129..6f45939 100755 > --- a/openbsc/tests/vty_test_runner.py > +++ b/openbsc/tests/vty_test_runner.py > @@ -205,6 +205,89 @@ class TestVTYNITB(TestVTYGenericBSC): > res = self.vty.command("write terminal") > self.assert_(res.find('auth policy black-list') > 0) > > + def testRachAccessControlClass(self): > + self.vty.enable() > + self.vty.command("configure terminal") > + self.vty.command("network") > + self.vty.command("bts 0") > + > + # Test invalid input > + self.vty.verify("rach access-control-class", ['% Command incomplete.']) > + self.vty.verify("rach access-control-class 1", ['% Command > incomplete.']) > + self.vty.verify("rach access-control-class -1", ['% Unknown command.']) > + self.vty.verify("rach access-control-class 10", ['% Unknown command.']) > + self.vty.verify("rach access-control-class 16", ['% Unknown command.']) > + > + # Barred rach access control classes > + self.vty.verify("rach access-control-class 0 barred", ['']) > + self.vty.verify("rach access-control-class 1 barred", ['']) > + self.vty.verify("rach access-control-class 2 barred", ['']) > + self.vty.verify("rach access-control-class 3 barred", ['']) > + self.vty.verify("rach access-control-class 4 barred", ['']) > + self.vty.verify("rach access-control-class 5 barred", ['']) > + self.vty.verify("rach access-control-class 6 barred", ['']) > + self.vty.verify("rach access-control-class 7 barred", ['']) > + self.vty.verify("rach access-control-class 8 barred", ['']) > + self.vty.verify("rach access-control-class 9 barred", ['']) > + self.vty.verify("rach access-control-class 11 barred", ['']) > + self.vty.verify("rach access-control-class 12 barred", ['']) > + self.vty.verify("rach access-control-class 13 barred", ['']) > + self.vty.verify("rach access-control-class 14 barred", ['']) > + self.vty.verify("rach access-control-class 15 barred", ['']) > + > + # Verify settings > + res = self.vty.command("write terminal") > + self.assert_(res.find('rach access-control-class 0 barred') > 0) > + self.assert_(res.find('rach access-control-class 1 barred') > 0) > + self.assert_(res.find('rach access-control-class 2 barred') > 0) > + self.assert_(res.find('rach access-control-class 3 barred') > 0) > + self.assert_(res.find('rach access-control-class 4 barred') > 0) > + self.assert_(res.find('rach access-control-class 5 barred') > 0) > + self.assert_(res.find('rach access-control-class 6 barred') > 0) > + self.assert_(res.find('rach access-control-class 7 barred') > 0) > + self.assert_(res.find('rach access-control-class 8 barred') > 0) > + self.assert_(res.find('rach access-control-class 9 barred') > 0) > + self.assert_(res.find('rach access-control-class 11 barred') > 0) > + self.assert_(res.find('rach access-control-class 12 barred') > 0) > + self.assert_(res.find('rach access-control-class 13 barred') > 0) > + self.assert_(res.find('rach access-control-class 14 barred') > 0) > + self.assert_(res.find('rach access-control-class 15 barred') > 0) > + > + # Allowed rach access control classes > + self.vty.verify("rach access-control-class 0 allowed", ['']) > + self.vty.verify("rach access-control-class 1 allowed", ['']) > + self.vty.verify("rach access-control-class 2 allowed", ['']) > + self.vty.verify("rach access-control-class 3 allowed", ['']) > + self.vty.verify("rach access-control-class 4 allowed", ['']) > + self.vty.verify("rach access-control-class 5 allowed", ['']) > + self.vty.verify("rach access-control-class 6 allowed", ['']) > + self.vty.verify("rach access-control-class 7 allowed", ['']) > + self.vty.verify("rach access-control-class 8 allowed", ['']) > + self.vty.verify("rach access-control-class 9 allowed", ['']) > + self.vty.verify("rach access-control-class 11 allowed", ['']) > + self.vty.verify("rach access-control-class 12 allowed", ['']) > + self.vty.verify("rach access-control-class 13 allowed", ['']) > + self.vty.verify("rach access-control-class 14 allowed", ['']) > + self.vty.verify("rach access-control-class 15 allowed", ['']) > + > + # Verify settings > + res = self.vty.command("write terminal") > + self.assertEquals(res.find('rach access-control-class 0 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 1 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 2 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 3 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 4 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 5 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 6 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 7 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 8 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 9 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 11 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 12 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 13 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 14 barred'), -1) > + self.assertEquals(res.find('rach access-control-class 15 barred'), -1) > + > class TestVTYBSC(TestVTYGenericBSC): > > def vty_command(self): > -- > 1.7.9.5 > > -- > Regards, > Ivan Kluchnikov. > http://fairwaves.ru -- Regards, Ivan Kluchnikov. http://fairwaves.ru From holger at freyther.de Fri Sep 13 19:26:58 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 13 Sep 2013 21:26:58 +0200 Subject: [PATCH 4/4] Added test for "rach access-control-class" VTY command. In-Reply-To: References: Message-ID: <20130913192658.GF7937@xiaoyu.lan> On Fri, Sep 13, 2013 at 07:59:03PM +0400, Ivan Kluchnikov wrote: Dear Ivan, it was just a question if you knew range. It is fine to decide not to use it. I just wanted to know. :) All patches look fine, I plan to integrate them on Sunday. holger From Ivan.Kluchnikov at fairwaves.ru Mon Sep 16 10:17:44 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Mon, 16 Sep 2013 14:17:44 +0400 Subject: [PATCH 4/4] Added test for "rach access-control-class" VTY command. In-Reply-To: <20130913192658.GF7937@xiaoyu.lan> References: <20130913192658.GF7937@xiaoyu.lan> Message-ID: 2013/9/13 Holger Hans Peter Freyther : > > it was just a question if you knew range. It is fine to decide not > to use it. I just wanted to know. :) I really think that last version of this patch looks much more better than previous. I know range, but in this case I just wrote code in "VTY-style" (command by command), but I think, that this style looks ugly, when we have fifteen identical commands :) -- Regards, Ivan Kluchnikov. http://fairwaves.ru From peter at stuge.se Mon Sep 16 10:52:10 2013 From: peter at stuge.se (Peter Stuge) Date: Mon, 16 Sep 2013 12:52:10 +0200 Subject: [PATCH 4/4] Added test for "rach access-control-class" VTY command. In-Reply-To: References: <20130913192658.GF7937@xiaoyu.lan> Message-ID: <20130916105210.28002.qmail@stuge.se> Ivan Kluchnikov wrote: > this style looks ugly, when we have fifteen identical commands :) That's why I suggested to use a list/range parser, and wrote it for you. //Peter From peter at stuge.se Fri Sep 13 22:59:22 2013 From: peter at stuge.se (Peter Stuge) Date: Sat, 14 Sep 2013 00:59:22 +0200 Subject: [PATCH 4/4] Added test for "rach access-control-class" VTY command. In-Reply-To: References: Message-ID: <20130913225922.21827.qmail@stuge.se> Hey, Ivan Kluchnikov wrote: > + # Barred rach access control classes > + self.vty.verify("rach access-control-class 0 barred", ['']) > + self.vty.verify("rach access-control-class 1 barred", ['']) > + self.vty.verify("rach access-control-class 2 barred", ['']) what happened to the code that I sent for parsing ranges and not just a single class digit? //Peter From holger at freyther.de Sun Sep 15 15:31:54 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sun, 15 Sep 2013 17:31:54 +0200 Subject: [PATCH 4/4] Added test for "rach access-control-class" VTY command. In-Reply-To: <20130913225922.21827.qmail@stuge.se> References: <20130913225922.21827.qmail@stuge.se> Message-ID: <20130915153154.GN11068@xiaoyu.lan> On Sat, Sep 14, 2013 at 12:59:22AM +0200, Peter Stuge wrote: > Hey, > > Ivan Kluchnikov wrote: > > + # Barred rach access control classes > > + self.vty.verify("rach access-control-class 0 barred", ['']) > > + self.vty.verify("rach access-control-class 1 barred", ['']) > > + self.vty.verify("rach access-control-class 2 barred", ['']) > > what happened to the code that I sent for parsing ranges and not just > a single class digit? can you re-send your patch/diff for that? I can help with the test case for that. From peter at stuge.se Sun Sep 15 17:22:00 2013 From: peter at stuge.se (Peter Stuge) Date: Sun, 15 Sep 2013 19:22:00 +0200 Subject: [PATCH 4/4] Added test for "rach access-control-class" VTY command. In-Reply-To: <20130915153154.GN11068@xiaoyu.lan> References: <20130913225922.21827.qmail@stuge.se> <20130915153154.GN11068@xiaoyu.lan> Message-ID: <20130915172200.10748.qmail@stuge.se> Holger Hans Peter Freyther wrote: > > > + # Barred rach access control classes > > > + self.vty.verify("rach access-control-class 0 barred", ['']) > > > + self.vty.verify("rach access-control-class 1 barred", ['']) > > > + self.vty.verify("rach access-control-class 2 barred", ['']) > > > > what happened to the code that I sent for parsing ranges and not just > > a single class digit? > > can you re-send your patch/diff for that? I can help with the test > case for that. I didn't make an actual patch, I only wrote and sent the range/list parsing code, since Alex wrote that it would get used it if I sent it. I'm attaching a cleaned-up version with all functionality moved to an actual function and now also featuring input validation not just for characters but also their meaning. Out-of-range list/range numbers are no longer silently ignored but cause an error. What's the best way to proceed? I suppose I could send a patch to add this function somewhere - maybe libosmocore? It should obviously log instead of sending to stderr then. //Peter -------------- next part -------------- #include #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif /* MIN */ #ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif /* MAX */ #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a)[0]) #endif /* ARRAY_SIZE */ int parse_range_list(const char *str, int *val, size_t n_val) { int i, ret = 0; unsigned int a, b; int n1, n2; while (*str) { switch (sscanf(str, "%u%n-%u%n", &a, &n1, &b, &n2)) { case -1: perror("sscanf"); return -1; case 0: goto invalid; case 1: if (a >= n_val) goto invalid; val[a] = 1; ret++; str += n1; break; case 2: if (a >= n_val || b >= n_val) goto invalid; for (i = MIN(a, b); i <= MAX(a, b); i++) { val[i] = 1; ret++; } str += n2; break; } if (',' == *str) str++; else if (*str) goto invalid; } return ret; invalid: fprintf(stderr, "invalid input at '%.5s'\n", str); return -1; } int main(int argc,const char *argv[]) { int i, val[16]; if (argc < 2) { fprintf(stderr, "usage: %s int[-int][,...]\n", *argv); return 1; } memset(val, 0, sizeof val); i = parse_range_list(argv[1], val, ARRAY_SIZE(val)); if (-1 == i) return 2; printf("parse_range_list() returns %d\n", i); for (i = 0; i < ARRAY_SIZE(val); i++) printf("val[%d]=%d\n", i, val[i]); return 0; } From jerlbeck at sysmocom.de Mon Sep 16 08:29:57 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 16 Sep 2013 10:29:57 +0200 Subject: [PATCH] gsm48: Added 'Network Daylight Saving Time' info element Message-ID: <1379320197-16372-1-git-send-email-jerlbeck@sysmocom.de> This information element has been added to the MM Information message in GSM24.008. This patch adds it to the tlv_definition to keep the TLV parser from breaking. Ticket: OW#978 --- include/osmocom/gsm/protocol/gsm_04_08.h | 1 + src/gsm/gsm48.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index bd6d707..8fa5d9a 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -925,6 +925,7 @@ struct gsm48_rr_status { #define GSM48_IE_UTC 0x46 /* 10.5.3.8 */ #define GSM48_IE_NET_TIME_TZ 0x47 /* 10.5.3.9 */ #define GSM48_IE_LSA_IDENT 0x48 /* 10.5.3.11 */ +#define GSM48_IE_NET_DST 0x49 /* 10.5.3.12 [24.008] */ #define GSM48_IE_BEARER_CAP 0x04 /* 10.5.4.5 */ #define GSM48_IE_CAUSE 0x08 /* 10.5.4.11 */ diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c index 313d9a3..80f7502 100644 --- a/src/gsm/gsm48.c +++ b/src/gsm/gsm48.c @@ -131,6 +131,7 @@ const struct tlv_definition gsm48_mm_att_tlvdef = { [GSM48_IE_UTC] = { TLV_TYPE_TV }, [GSM48_IE_NET_TIME_TZ] = { TLV_TYPE_FIXED, 7 }, [GSM48_IE_LSA_IDENT] = { TLV_TYPE_TLV }, + [GSM48_IE_NET_DST] = { TLV_TYPE_TLV }, [GSM48_IE_LOCATION_AREA] = { TLV_TYPE_FIXED, 5 }, [GSM48_IE_PRIORITY_LEV] = { TLV_TYPE_SINGLE_TV }, -- 1.7.9.5 From kluchnikovi at gmail.com Mon Sep 16 09:13:02 2013 From: kluchnikovi at gmail.com (Ivan Kluchnikov) Date: Mon, 16 Sep 2013 13:13:02 +0400 Subject: [PATCH 1/4] Added new auth policy black-list. Message-ID: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> In this mode by default we set authorized = 1 for all new subscribers. BSC accepts all MS, except subscribers not authorized in DB. All subscribers with authorized = 0 are part of the black list and not accepted. --- openbsc/include/openbsc/gsm_data.h | 1 + openbsc/src/libbsc/bsc_vty.c | 5 +++-- openbsc/src/libcommon/gsm_data.c | 1 + openbsc/src/libmsc/db.c | 12 +++++++++--- openbsc/src/libmsc/gsm_04_08.c | 2 ++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 8741505..99e9b27 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -194,6 +194,7 @@ enum gsm_auth_policy { GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */ GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */ GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */ + GSM_AUTH_POLICY_BLACK_LIST /* accept everyone, except subscribers not authorized in DB */ }; #define GSM_T3101_DEFAULT 10 diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 5748945..7a89ca6 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -1186,12 +1186,13 @@ DEFUN(cfg_net_name_long, DEFUN(cfg_net_auth_policy, cfg_net_auth_policy_cmd, - "auth policy (closed|accept-all|token)", + "auth policy (closed|accept-all|token|black-list)", "Authentication (not cryptographic)\n" "Set the GSM network authentication policy\n" "Require the MS to be activated in HLR\n" "Accept all MS, whether in HLR or not\n" - "Use SMS-token based authentication\n") + "Use SMS-token based authentication\n" + "Accept all MS, except not authorized in HLR\n") { enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]); struct gsm_network *gsmnet = gsmnet_from_vty(vty); diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c index 5f7e32e..31b65ee 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -256,6 +256,7 @@ static const struct value_string auth_policy_names[] = { { GSM_AUTH_POLICY_CLOSED, "closed" }, { GSM_AUTH_POLICY_ACCEPT_ALL, "accept-all" }, { GSM_AUTH_POLICY_TOKEN, "token" }, + { GSM_AUTH_POLICY_BLACK_LIST, "black-list"}, { 0, NULL } }; diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 21abce9..440509a 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -319,6 +319,7 @@ struct gsm_subscriber *db_create_subscriber(struct gsm_network *net, char *imsi) { dbi_result result; struct gsm_subscriber *subscr; + int authorized = 0; /* Is this subscriber known in the db? */ subscr = db_get_subscriber(net, GSM_SUBSCRIBER_IMSI, imsi); @@ -337,17 +338,22 @@ struct gsm_subscriber *db_create_subscriber(struct gsm_network *net, char *imsi) if (!subscr) return NULL; subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; + + if (net->auth_policy == GSM_AUTH_POLICY_BLACK_LIST) + authorized = 1; + result = dbi_conn_queryf(conn, "INSERT INTO Subscriber " - "(imsi, created, updated) " + "(imsi, created, updated, authorized) " "VALUES " - "(%s, datetime('now'), datetime('now')) ", - imsi + "(%s, datetime('now'), datetime('now'), %d) ", + imsi, authorized ); if (!result) LOGP(DDB, LOGL_ERROR, "Failed to create Subscriber by IMSI.\n"); subscr->net = net; subscr->id = dbi_conn_sequence_last(conn, NULL); + subscr->authorized = authorized; strncpy(subscr->imsi, imsi, GSM_IMSI_LENGTH-1); dbi_result_free(result); LOGP(DDB, LOGL_INFO, "New Subscriber: ID %llu, IMSI %s\n", subscr->id, subscr->imsi); diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index d81dab9..8f8eaa9 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -241,6 +241,8 @@ static int authorize_subscriber(struct gsm_loc_updating_operation *loc, return (subscriber->flags & GSM_SUBSCRIBER_FIRST_CONTACT); case GSM_AUTH_POLICY_ACCEPT_ALL: return 1; + case GSM_AUTH_POLICY_BLACK_LIST: + return subscriber->authorized; default: return 0; } -- 1.7.9.5 From kluchnikovi at gmail.com Mon Sep 16 09:13:03 2013 From: kluchnikovi at gmail.com (Ivan Kluchnikov) Date: Mon, 16 Sep 2013 13:13:03 +0400 Subject: [PATCH 2/4] Added test for "auth policy" VTY command. In-Reply-To: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> References: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> Message-ID: <1379322785-9727-2-git-send-email-kluchnikovi@gmail.com> --- openbsc/tests/vty_test_runner.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) mode change 100644 => 100755 openbsc/tests/vty_test_runner.py diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py old mode 100644 new mode 100755 index ab9670c..3594129 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -169,6 +169,42 @@ class TestVTYNITB(TestVTYGenericBSC): self.assertEquals(res.find('periodic location update 60'), -1) self.assert_(res.find('no periodic location update') > 0) + def testAuthPolicy (self): + self.vty.enable() + self.vty.command("configure terminal") + self.vty.command("network") + + # Test invalid input + self.vty.verify("auth policy", ['% Command incomplete.']) + + # Enable auth policy closed + self.vty.verify("auth policy closed", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('auth policy closed') > 0) + + # Enable auth policy accept-all + self.vty.verify("auth policy accept-all", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('auth policy accept-all') > 0) + + # Enable auth policy token + self.vty.verify("auth policy token", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('auth policy token') > 0) + + # Enable auth policy black-list + self.vty.verify("auth policy black-list", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('auth policy black-list') > 0) + class TestVTYBSC(TestVTYGenericBSC): def vty_command(self): -- 1.7.9.5 From kluchnikovi at gmail.com Mon Sep 16 09:13:04 2013 From: kluchnikovi at gmail.com (Ivan Kluchnikov) Date: Mon, 16 Sep 2013 13:13:04 +0400 Subject: [PATCH 3/4] Added vty command for setting Access control classes. In-Reply-To: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> References: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> Message-ID: <1379322785-9727-3-git-send-email-kluchnikovi@gmail.com> --- openbsc/src/libbsc/bsc_vty.c | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 7a89ca6..a06aa90 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -539,6 +539,14 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) vty_out(vty, " cell barred 1%s", VTY_NEWLINE); if ((bts->si_common.rach_control.t2 & 0x4) == 0) vty_out(vty, " rach emergency call allowed 1%s", VTY_NEWLINE); + if ((bts->si_common.rach_control.t3) != 0) + for (i = 0; i < 8; i++) + if (bts->si_common.rach_control.t3 & (0x1 << i)) + vty_out(vty, " rach access-control-class %d barred%s", i, VTY_NEWLINE); + if ((bts->si_common.rach_control.t2 & 0xfb) != 0) + for (i = 0; i < 8; i++) + if ((i != 2) && (bts->si_common.rach_control.t2 & (0x1 << i))) + vty_out(vty, " rach access-control-class %d barred%s", i+8, VTY_NEWLINE); for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) { if (bts->si_mode_static & (1 << i)) { vty_out(vty, " system-information %s mode static%s", @@ -1899,6 +1907,51 @@ DEFUN(cfg_bts_rach_ec_allowed, cfg_bts_rach_ec_allowed_cmd, return CMD_SUCCESS; } +DEFUN(cfg_bts_rach_ac_class, cfg_bts_rach_ac_class_cmd, + "rach access-control-class (0|1|2|3|4|5|6|7|8|9|11|12|13|14|15) (barred|allowed)", + RACH_STR + "Set access control class\n" + "Access control class 0\n" + "Access control class 1\n" + "Access control class 2\n" + "Access control class 3\n" + "Access control class 4\n" + "Access control class 5\n" + "Access control class 6\n" + "Access control class 7\n" + "Access control class 8\n" + "Access control class 9\n" + "Access control class 11 for PLMN use\n" + "Access control class 12 for security services\n" + "Access control class 13 for public utilities (e.g. water/gas suppliers)\n" + "Access control class 14 for emergency services\n" + "Access control class 15 for PLMN staff\n" + "barred to use access control class\n" + "allowed to use access control class\n") +{ + struct gsm_bts *bts = vty->index; + + uint8_t control_class; + uint8_t allowed = 0; + + if (strcmp(argv[1],"allowed") == 0) + allowed = 1; + + control_class = atoi(argv[0]); + if (control_class < 8) + if (allowed) + bts->si_common.rach_control.t3 &= ~(0x1 << control_class); + else + bts->si_common.rach_control.t3 |= (0x1 << control_class); + else + if (allowed) + bts->si_common.rach_control.t2 &= ~(0x1 << (control_class - 8)); + else + bts->si_common.rach_control.t2 |= (0x1 << (control_class - 8)); + + return CMD_SUCCESS; +} + DEFUN(cfg_bts_ms_max_power, cfg_bts_ms_max_power_cmd, "ms max power <0-40>", "MS Options\n" @@ -3066,6 +3119,7 @@ int bsc_vty_init(const struct log_info *cat) install_element(BTS_NODE, &cfg_bts_rach_nm_ldavg_cmd); install_element(BTS_NODE, &cfg_bts_cell_barred_cmd); install_element(BTS_NODE, &cfg_bts_rach_ec_allowed_cmd); + install_element(BTS_NODE, &cfg_bts_rach_ac_class_cmd); install_element(BTS_NODE, &cfg_bts_ms_max_power_cmd); install_element(BTS_NODE, &cfg_bts_per_loc_upd_cmd); install_element(BTS_NODE, &cfg_bts_no_per_loc_upd_cmd); -- 1.7.9.5 From kluchnikovi at gmail.com Mon Sep 16 09:13:05 2013 From: kluchnikovi at gmail.com (Ivan Kluchnikov) Date: Mon, 16 Sep 2013 13:13:05 +0400 Subject: [PATCH 4/4] Added test for "rach access-control-class" VTY command. In-Reply-To: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> References: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> Message-ID: <1379322785-9727-4-git-send-email-kluchnikovi@gmail.com> --- openbsc/tests/vty_test_runner.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 3594129..1e25a91 100755 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -205,6 +205,41 @@ class TestVTYNITB(TestVTYGenericBSC): res = self.vty.command("write terminal") self.assert_(res.find('auth policy black-list') > 0) + def testRachAccessControlClass(self): + self.vty.enable() + self.vty.command("configure terminal") + self.vty.command("network") + self.vty.command("bts 0") + + # Test invalid input + self.vty.verify("rach access-control-class", ['% Command incomplete.']) + self.vty.verify("rach access-control-class 1", ['% Command incomplete.']) + self.vty.verify("rach access-control-class -1", ['% Unknown command.']) + self.vty.verify("rach access-control-class 10", ['% Unknown command.']) + self.vty.verify("rach access-control-class 16", ['% Unknown command.']) + + # Barred rach access control classes + for classNum in range(16): + if classNum!=10: + self.vty.verify("rach access-control-class " + str(classNum) + " barred", ['']) + + # Verify settings + res = self.vty.command("write terminal") + for classNum in range(16): + if classNum!=10: + self.assert_(res.find("rach access-control-class " + str(classNum) + " barred") > 0) + + # Allowed rach access control classes + for classNum in range(16): + if classNum!=10: + self.vty.verify("rach access-control-class " + str(classNum) + " allowed", ['']) + + # Verify settings + res = self.vty.command("write terminal") + for classNum in range(16): + if classNum!=10: + self.assertEquals(res.find("rach access-control-class " + str(classNum) + " barred"), -1) + class TestVTYBSC(TestVTYGenericBSC): def vty_command(self): -- 1.7.9.5 From holger at freyther.de Wed Sep 18 14:14:31 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 18 Sep 2013 16:14:31 +0200 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> References: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> Message-ID: <20130918141431.GA9120@xiaoyu.lan> On Mon, Sep 16, 2013 at 01:13:02PM +0400, Ivan Kluchnikov wrote: > + > + if (net->auth_policy == GSM_AUTH_POLICY_BLACK_LIST) > + authorized = 1; this causes a segfault in the tests (as there is no network that we pass). E.g. make check is failing. On second thought I wonder about the semantic of this patch. E.g. if I run an accept-all network.. and then switch to a closed policy. The authorized field will still be 0. But with this change I can not easily change. Have you considered using an enum like enum { AUTHORIZED_NOTSET, AUTHORIZED_ALLOWED, AUTHORIZES_BLACKLISTED, }; > + return subscriber->authorized; return subscriber->authorized != AUTHORIZES_BLACKLISTED? doesn't look too bad and one avoids the using net inside the db code. From Ivan.Kluchnikov at fairwaves.ru Wed Sep 18 17:01:09 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Wed, 18 Sep 2013 21:01:09 +0400 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: <20130918141431.GA9120@xiaoyu.lan> References: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> <20130918141431.GA9120@xiaoyu.lan> Message-ID: Hi Holger, 2013/9/18 Holger Hans Peter Freyther : > this causes a segfault in the tests (as there is no network that > we pass). E.g. make check is failing. Yes, I missed "make check", I will fix db test to support our case. > On second thought I wonder about the semantic of this patch. E.g. > if I run an accept-all network.. and then switch to a closed > policy. The authorized field will still be 0. But with this change > I can not easily change. For auth policy clarification: accept-all = accept MS with authorized = 1 and 0, for all new subscribers set authorized = 0 closed = accept MS with authorized = 1, MS with authorized = 0 and all new subscribers should be rejected black-list = accept MS with authorized = 1, MS with authorized = 0 should be rejected, for all new subscribers set authorized = 1 You can see, that "black-list" is like "closed", but in black-list mode we set authorized = 1 for all new subscribers. So the idea was to save meaning of authorized parameter, accept with authorized = 1 and reject with authorized = 0. > > Have you considered using an enum like > > enum { > AUTHORIZED_NOTSET, > AUTHORIZED_ALLOWED, > AUTHORIZES_BLACKLISTED, > }; > > >> + return subscriber->authorized; > > return subscriber->authorized != AUTHORIZES_BLACKLISTED? > > doesn't look too bad and one avoids the using net inside the db > code. What's the problem to use net inside the db code? Moreover, net is used in db_create_subscriber() function. -- Regards, Ivan Kluchnikov. http://fairwaves.ru From holger at freyther.de Thu Sep 19 06:33:04 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 19 Sep 2013 08:33:04 +0200 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: References: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> <20130918141431.GA9120@xiaoyu.lan> Message-ID: <20130919063304.GD6940@xiaoyu.lan> On Wed, Sep 18, 2013 at 09:01:09PM +0400, Ivan Kluchnikov wrote: > > On second thought I wonder about the semantic of this patch. E.g. > > if I run an accept-all network.. and then switch to a closed > > policy. The authorized field will still be 0. But with this change > > I can not easily change. > > For auth policy clarification: > accept-all = accept MS with authorized = 1 and 0, for all new > subscribers set authorized = 0 > closed = accept MS with authorized = 1, MS with authorized = 0 and > all new subscribers should be rejected > black-list = accept MS with authorized = 1, MS with authorized = 0 > should be rejected, for all new subscribers set authorized = 1 > > You can see, that "black-list" is like "closed", but in black-list > mode we set authorized = 1 for all new subscribers. > So the idea was to save meaning of authorized parameter, accept with > authorized = 1 and reject with authorized = 0. My point was that. Currently I can do: 1.) accept-all policy... new subscribers will be allowed to register send/sms/added to the database but their actually authorized=1 2.) I decide to change to closed. All previous subscribers are not allowed in anymore. This means I can change policy without updating the database. I think it would be nice for the black-list too. > > What's the problem to use net inside the db code? > Moreover, net is used in db_create_subscriber() function. It is a layering violation. The DB code should know little about the gsm_network. It should just save and restore records. We should assign subscriber->net outside of the code. From Ivan.Kluchnikov at fairwaves.ru Thu Sep 19 12:22:31 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Thu, 19 Sep 2013 16:22:31 +0400 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: <20130919063304.GD6940@xiaoyu.lan> References: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> <20130918141431.GA9120@xiaoyu.lan> <20130919063304.GD6940@xiaoyu.lan> Message-ID: Hi Holger, > My point was that. Currently I can do: > > 1.) accept-all policy... new subscribers will be allowed to register > send/sms/added to the database but their actually authorized=1 As I know, we set authorized=0 for all new subscribers by default "authorized INTEGER NOT NULL DEFAULT 0, " > > 2.) I decide to change to closed. All previous subscribers are not > allowed in anymore. > > This means I can change policy without updating the database. Yes, this logic will work after my changes too. > I think > it would be nice for the black-list too. For black-list you can do: 1. accept-all policy. New subscribers will be allowed to register send/sms/added to the database with authorized=0 2. Change to black-list. All previous subscribers are not allowed in anymore. New subscribers will be allowed to register send/sms/added to the database with authorized=1 So the logic, which I described above, is what I really want to implement. > It is a layering violation. The DB code should know little about > the gsm_network. It should just save and restore records. We should > assign subscriber->net outside of the code. I think the problem is that db_create_subscriber() function not only saves and restores records, but also creates subscriber. So I believe, that the right way is to add new layer "subscriber" and separate db_create_subscriber() function in two functions like create_subscriber() [subscriber layer] and db_set_subscriber() [db layer]. -- Regards, Ivan Kluchnikov. http://fairwaves.ru From holger at freyther.de Thu Sep 19 15:09:58 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 19 Sep 2013 17:09:58 +0200 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: References: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> <20130918141431.GA9120@xiaoyu.lan> <20130919063304.GD6940@xiaoyu.lan> Message-ID: <20130919150958.GM6940@xiaoyu.lan> On Thu, Sep 19, 2013 at 04:22:31PM +0400, Ivan Kluchnikov wrote: > > Yes, this logic will work after my changes too. We don't talk the same language here. With your change.. all subscribers that were allowed in during the blacklist mode are now authorized=1. So, if I want to change the policy, I will need to update the database. > I think the problem is that db_create_subscriber() function not only > saves and restores records, but also creates subscriber. > So I believe, that the right way is to add new layer "subscriber" and > separate db_create_subscriber() function in two functions like > create_subscriber() [subscriber layer] and db_set_subscriber() [db > layer]. makes sense. I plan to clean that up. From peter at stuge.se Thu Sep 19 17:39:54 2013 From: peter at stuge.se (Peter Stuge) Date: Thu, 19 Sep 2013 19:39:54 +0200 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> References: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> Message-ID: <20130919173954.3473.qmail@stuge.se> Please call it "blacklist" without the dash. Splitting it into two words means a list of the colour black, which is very different from the term blacklist. :) Remember to update the commit message too. Thanks! //Peter From holger at freyther.de Fri Sep 20 14:21:50 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 20 Sep 2013 16:21:50 +0200 Subject: [PATCH 1/4] Added new auth policy black-list. In-Reply-To: <20130919173954.3473.qmail@stuge.se> References: <1379322785-9727-1-git-send-email-kluchnikovi@gmail.com> <20130919173954.3473.qmail@stuge.se> Message-ID: <20130920142150.GA16576@xiaoyu.lan> On Thu, Sep 19, 2013 at 07:39:54PM +0200, Peter Stuge wrote: > Please call it "blacklist" without the dash. > > Splitting it into two words means a list of the colour black, > which is very different from the term blacklist. :) oops. thanks! From jerlbeck at sysmocom.de Mon Sep 16 12:50:14 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 16 Sep 2013 14:50:14 +0200 Subject: [PATCH] bsc/mminfo: Patch timezone and DST in MM Info messages Message-ID: <1379335814-7416-1-git-send-email-jerlbeck@sysmocom.de> This adds in-place patching of the time information in the MM INFORMATION message. The timezone in the 'Local time zone' and the 'Universal time and local time zone' information elements and the offset in the 'Network Daylight Saving Time' information element are optionally set. The new values are determined by the 'timezone' vty command in the config_net_bts node. That command is extended by an optional DST offset parameter. Ticket: OW#978 --- openbsc/include/openbsc/gsm_data_shared.h | 1 + openbsc/src/libbsc/bsc_vty.c | 37 +++++++++++++++++- openbsc/src/osmo-bsc/osmo_bsc_filter.c | 58 ++++++++++++++++++++++++++++- openbsc/tests/vty_test_runner.py | 34 +++++++++++++++++ 4 files changed, 127 insertions(+), 3 deletions(-) diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h index 3ef1457..437378a 100644 --- a/openbsc/include/openbsc/gsm_data_shared.h +++ b/openbsc/include/openbsc/gsm_data_shared.h @@ -594,6 +594,7 @@ struct gsm_bts { int hr; int mn; int override; + int dst; } tz; /* ip.accesss Unit ID's have Site/BTS/TRX layout */ diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 2cbcf44..7c0d998 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -489,8 +489,14 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) VTY_NEWLINE); vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE); vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE); - if (bts->tz.override != 0) - vty_out(vty, " timezone %d %d%s", bts->tz.hr, bts->tz.mn, VTY_NEWLINE); + if (bts->tz.override != 0) { + if (bts->tz.dst) + vty_out(vty, " timezone %d %d %d%s", + bts->tz.hr, bts->tz.mn, bts->tz.dst, VTY_NEWLINE); + else + vty_out(vty, " timezone %d %d%s", + bts->tz.hr, bts->tz.mn, VTY_NEWLINE); + } vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE); vty_out(vty, " cell reselection hysteresis %u%s", bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE); @@ -1613,6 +1619,32 @@ DEFUN(cfg_bts_timezone, bts->tz.hr = tzhr; bts->tz.mn = tzmn; + bts->tz.dst = 0; + bts->tz.override = 1; + + return CMD_SUCCESS; +} + +DEFUN(cfg_bts_timezone_dst, + cfg_bts_timezone_dst_cmd, + "timezone <-19-19> (0|15|30|45) <0-2>", + "Set the Timezone Offset of this BTS\n" + "Timezone offset (hours)\n" + "Timezone offset (00 minutes)\n" + "Timezone offset (15 minutes)\n" + "Timezone offset (30 minutes)\n" + "Timezone offset (45 minutes)\n" + "DST offset (hours)\n" + ) +{ + struct gsm_bts *bts = vty->index; + int tzhr = atoi(argv[0]); + int tzmn = atoi(argv[1]); + int tzdst = atoi(argv[2]); + + bts->tz.hr = tzhr; + bts->tz.mn = tzmn; + bts->tz.dst = tzdst; bts->tz.override = 1; return CMD_SUCCESS; @@ -3064,6 +3096,7 @@ int bsc_vty_init(const struct log_info *cat) install_element(BTS_NODE, &cfg_bts_unit_id_cmd); install_element(BTS_NODE, &cfg_bts_rsl_ip_cmd); install_element(BTS_NODE, &cfg_bts_timezone_cmd); + install_element(BTS_NODE, &cfg_bts_timezone_dst_cmd); install_element(BTS_NODE, &cfg_bts_no_timezone_cmd); install_element(BTS_NODE, &cfg_bts_nokia_site_skip_reset_cmd); install_element(BTS_NODE, &cfg_bts_stream_id_cmd); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index 957ceaf..6b8313e 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -251,6 +251,57 @@ int bsc_send_welcome_ussd(struct gsm_subscriber_connection *conn) return 0; } +static int bsc_patch_mm_info(struct gsm_subscriber_connection *conn, + uint8_t *data, unsigned int length) +{ + struct tlv_parsed tp; + int parse_res; + struct gsm_bts *bts = conn->bts; + + parse_res = tlv_parse(&tp, &gsm48_mm_att_tlvdef, data, length, 0, 0); + if (parse_res <= 0 && parse_res != -3) + return 0; + + if (bts->tz.override) { + /* TZ patching is enabled */ + int tzunits; + uint8_t tzbsd = 0; + uint8_t dst = 0; + + /* Convert tz.hr and tz.mn to units */ + if (bts->tz.hr < 0) { + tzunits = -bts->tz.hr*4; + tzbsd |= 0x08; + } else + tzunits = bts->tz.hr*4; + + tzunits = tzunits + (bts->tz.mn/15); + + tzbsd |= (tzunits % 10)*0x10 + (tzunits / 10); + + /* Convert DST value */ + if (bts->tz.dst >= 0 && bts->tz.dst <= 2) + dst = bts->tz.dst; + + if (TLVP_PRESENT(&tp, GSM48_IE_UTC)) { + LOGP(DMSC, LOGL_DEBUG, "Changing 'Local time zone' from 0x%02x to 0x%02x.\n", TLVP_VAL(&tp, GSM48_IE_UTC)[6], tzbsd); + ((uint8_t *)(TLVP_VAL(&tp, GSM48_IE_UTC)))[0] = tzbsd; + } + if (TLVP_PRESENT(&tp, GSM48_IE_NET_TIME_TZ)) { + LOGP(DMSC, LOGL_DEBUG, "Changing 'Universal time and local time zone' TZ from 0x%02x to 0x%02x.\n", TLVP_VAL(&tp, GSM48_IE_NET_TIME_TZ)[6], tzbsd); + ((uint8_t *)(TLVP_VAL(&tp, GSM48_IE_NET_TIME_TZ)))[6] = tzbsd; + } +#ifdef GSM48_IE_NET_DST + if (TLVP_PRESENT(&tp, GSM48_IE_NET_DST)) { + LOGP(DMSC, LOGL_DEBUG, "Changing 'Network daylight saving time' from 0x%02x to 0x%02x.\n", TLVP_VAL(&tp, GSM48_IE_NET_DST)[0], dst); + ((uint8_t *)(TLVP_VAL(&tp, GSM48_IE_NET_DST)))[0] = dst; + } +#endif + } + + return 0; +} + /** * Messages coming back from the MSC. */ @@ -261,13 +312,16 @@ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) struct gsm48_loc_area_id *lai; struct gsm48_hdr *gh; uint8_t mtype; + int length = msgb_l3len(msg); - if (msgb_l3len(msg) < sizeof(*gh)) { + if (length < sizeof(*gh)) { LOGP(DMSC, LOGL_ERROR, "GSM48 header does not fit.\n"); return -1; } gh = (struct gsm48_hdr *) msgb_l3(msg); + length -= (const char *)&gh->data[0] - (const char *)gh; + mtype = gh->msg_type & 0xbf; net = conn->bts->network; msc = conn->sccp_con->msc; @@ -285,6 +339,8 @@ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) if (conn->sccp_con->new_subscriber) return send_welcome_ussd(conn); return 0; + } else if (mtype == GSM48_MT_MM_INFO) { + bsc_patch_mm_info(conn, &gh->data[0], length); } return 0; diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 7f71288..c0ba57d 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -280,6 +280,40 @@ class TestVTYBSC(TestVTYGenericBSC): self.assertEquals(res.find('missing-msc-text No MSC found'), -1) self.assert_(res.find('no missing-msc-text') > 0) + def testNetworkTimezone(self): + self.vty.enable() + self.vty.verify("configure terminal", ['']) + self.vty.verify("network", ['']) + self.vty.verify("bts 0", ['']) + + # Test invalid input + self.vty.verify("timezone", ['% Command incomplete.']) + self.vty.verify("timezone 20 0", ['% Unknown command.']) + self.vty.verify("timezone 0 11", ['% Unknown command.']) + self.vty.verify("timezone 0 0 99", ['% Unknown command.']) + + # Set time zone without DST + self.vty.verify("timezone 2 30", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('timezone 2 30') > 0) + self.assertEquals(res.find('timezone 2 30 '), -1) + + # Set time zone with DST + self.vty.verify("timezone 2 30 1", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('timezone 2 30 1') > 0) + + # Now disable it.. + self.vty.verify("no timezone", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assertEquals(res.find(' timezone'), -1) + class TestVTYNAT(TestVTYGenericBSC): def vty_command(self): -- 1.7.9.5 From jerlbeck at sysmocom.de Tue Sep 17 11:59:29 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Tue, 17 Sep 2013 13:59:29 +0200 Subject: [PATCH] bsc/mminfo: Patch timezone and DST in MM Info messages In-Reply-To: <1379335814-7416-1-git-send-email-jerlbeck@sysmocom.de> References: <1379335814-7416-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1379419169-17036-1-git-send-email-jerlbeck@sysmocom.de> This adds in-place patching of the time information in the MM INFORMATION message. The timezone in the 'Local time zone' and the 'Universal time and local time zone' information elements and the offset in the 'Network Daylight Saving Time' information element are optionally set. The new values are determined by the 'timezone' vty command in the config_net_bts node. That command is extended by an optional DST offset parameter. Tests are provided for the vty part and for the plain bsc_scan_msc_msg() function. Ticket: OW#978 --- openbsc/configure.ac | 4 +- openbsc/include/openbsc/gsm_data_shared.h | 1 + openbsc/src/libbsc/bsc_vty.c | 37 +++++- openbsc/src/osmo-bsc/osmo_bsc_filter.c | 58 ++++++++- openbsc/tests/Makefile.am | 4 + openbsc/tests/atlocal.in | 1 + openbsc/tests/bsc/Makefile.am | 19 +++ openbsc/tests/bsc/bsc_test.c | 193 +++++++++++++++++++++++++++++ openbsc/tests/bsc/bsc_test.ok | 4 + openbsc/tests/testsuite.at | 8 ++ openbsc/tests/vty_test_runner.py | 34 +++++ 11 files changed, 359 insertions(+), 4 deletions(-) create mode 100644 openbsc/tests/bsc/Makefile.am create mode 100644 openbsc/tests/bsc/bsc_test.c create mode 100644 openbsc/tests/bsc/bsc_test.ok diff --git a/openbsc/configure.ac b/openbsc/configure.ac index ce2a328..ddd15e3 100644 --- a/openbsc/configure.ac +++ b/openbsc/configure.ac @@ -36,11 +36,12 @@ AC_SUBST(osmo_ac_build_nat) # Enable/disable the BSC? AC_ARG_ENABLE([osmo-bsc], [AS_HELP_STRING([--enable-osmo-bsc], [Build the Osmo BSC])], - [osmo_ac_build_bsc="$enableval"]) + [osmo_ac_build_bsc="$enableval"],[osmo_ac_build_bsc="no"]) if test "$osmo_ac_build_bsc" = "yes" ; then PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.0.6) fi AM_CONDITIONAL(BUILD_BSC, test "x$osmo_ac_build_bsc" = "xyes") +AC_SUBST(osmo_ac_build_bsc) # Enable/disable smpp support in the nitb? AC_ARG_ENABLE([smpp], [AS_HELP_STRING([--enable-smpp], [Build the SMPP interface])], @@ -156,6 +157,7 @@ AC_OUTPUT( tests/gsm0408/Makefile tests/db/Makefile tests/channel/Makefile + tests/bsc/Makefile tests/bsc-nat/Makefile tests/bsc-nat-trie/Makefile tests/mgcp/Makefile diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h index 3ef1457..437378a 100644 --- a/openbsc/include/openbsc/gsm_data_shared.h +++ b/openbsc/include/openbsc/gsm_data_shared.h @@ -594,6 +594,7 @@ struct gsm_bts { int hr; int mn; int override; + int dst; } tz; /* ip.accesss Unit ID's have Site/BTS/TRX layout */ diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 2cbcf44..7c0d998 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -489,8 +489,14 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) VTY_NEWLINE); vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE); vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE); - if (bts->tz.override != 0) - vty_out(vty, " timezone %d %d%s", bts->tz.hr, bts->tz.mn, VTY_NEWLINE); + if (bts->tz.override != 0) { + if (bts->tz.dst) + vty_out(vty, " timezone %d %d %d%s", + bts->tz.hr, bts->tz.mn, bts->tz.dst, VTY_NEWLINE); + else + vty_out(vty, " timezone %d %d%s", + bts->tz.hr, bts->tz.mn, VTY_NEWLINE); + } vty_out(vty, " ms max power %u%s", bts->ms_max_power, VTY_NEWLINE); vty_out(vty, " cell reselection hysteresis %u%s", bts->si_common.cell_sel_par.cell_resel_hyst*2, VTY_NEWLINE); @@ -1613,6 +1619,32 @@ DEFUN(cfg_bts_timezone, bts->tz.hr = tzhr; bts->tz.mn = tzmn; + bts->tz.dst = 0; + bts->tz.override = 1; + + return CMD_SUCCESS; +} + +DEFUN(cfg_bts_timezone_dst, + cfg_bts_timezone_dst_cmd, + "timezone <-19-19> (0|15|30|45) <0-2>", + "Set the Timezone Offset of this BTS\n" + "Timezone offset (hours)\n" + "Timezone offset (00 minutes)\n" + "Timezone offset (15 minutes)\n" + "Timezone offset (30 minutes)\n" + "Timezone offset (45 minutes)\n" + "DST offset (hours)\n" + ) +{ + struct gsm_bts *bts = vty->index; + int tzhr = atoi(argv[0]); + int tzmn = atoi(argv[1]); + int tzdst = atoi(argv[2]); + + bts->tz.hr = tzhr; + bts->tz.mn = tzmn; + bts->tz.dst = tzdst; bts->tz.override = 1; return CMD_SUCCESS; @@ -3064,6 +3096,7 @@ int bsc_vty_init(const struct log_info *cat) install_element(BTS_NODE, &cfg_bts_unit_id_cmd); install_element(BTS_NODE, &cfg_bts_rsl_ip_cmd); install_element(BTS_NODE, &cfg_bts_timezone_cmd); + install_element(BTS_NODE, &cfg_bts_timezone_dst_cmd); install_element(BTS_NODE, &cfg_bts_no_timezone_cmd); install_element(BTS_NODE, &cfg_bts_nokia_site_skip_reset_cmd); install_element(BTS_NODE, &cfg_bts_stream_id_cmd); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c index 957ceaf..6b8313e 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c @@ -251,6 +251,57 @@ int bsc_send_welcome_ussd(struct gsm_subscriber_connection *conn) return 0; } +static int bsc_patch_mm_info(struct gsm_subscriber_connection *conn, + uint8_t *data, unsigned int length) +{ + struct tlv_parsed tp; + int parse_res; + struct gsm_bts *bts = conn->bts; + + parse_res = tlv_parse(&tp, &gsm48_mm_att_tlvdef, data, length, 0, 0); + if (parse_res <= 0 && parse_res != -3) + return 0; + + if (bts->tz.override) { + /* TZ patching is enabled */ + int tzunits; + uint8_t tzbsd = 0; + uint8_t dst = 0; + + /* Convert tz.hr and tz.mn to units */ + if (bts->tz.hr < 0) { + tzunits = -bts->tz.hr*4; + tzbsd |= 0x08; + } else + tzunits = bts->tz.hr*4; + + tzunits = tzunits + (bts->tz.mn/15); + + tzbsd |= (tzunits % 10)*0x10 + (tzunits / 10); + + /* Convert DST value */ + if (bts->tz.dst >= 0 && bts->tz.dst <= 2) + dst = bts->tz.dst; + + if (TLVP_PRESENT(&tp, GSM48_IE_UTC)) { + LOGP(DMSC, LOGL_DEBUG, "Changing 'Local time zone' from 0x%02x to 0x%02x.\n", TLVP_VAL(&tp, GSM48_IE_UTC)[6], tzbsd); + ((uint8_t *)(TLVP_VAL(&tp, GSM48_IE_UTC)))[0] = tzbsd; + } + if (TLVP_PRESENT(&tp, GSM48_IE_NET_TIME_TZ)) { + LOGP(DMSC, LOGL_DEBUG, "Changing 'Universal time and local time zone' TZ from 0x%02x to 0x%02x.\n", TLVP_VAL(&tp, GSM48_IE_NET_TIME_TZ)[6], tzbsd); + ((uint8_t *)(TLVP_VAL(&tp, GSM48_IE_NET_TIME_TZ)))[6] = tzbsd; + } +#ifdef GSM48_IE_NET_DST + if (TLVP_PRESENT(&tp, GSM48_IE_NET_DST)) { + LOGP(DMSC, LOGL_DEBUG, "Changing 'Network daylight saving time' from 0x%02x to 0x%02x.\n", TLVP_VAL(&tp, GSM48_IE_NET_DST)[0], dst); + ((uint8_t *)(TLVP_VAL(&tp, GSM48_IE_NET_DST)))[0] = dst; + } +#endif + } + + return 0; +} + /** * Messages coming back from the MSC. */ @@ -261,13 +312,16 @@ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) struct gsm48_loc_area_id *lai; struct gsm48_hdr *gh; uint8_t mtype; + int length = msgb_l3len(msg); - if (msgb_l3len(msg) < sizeof(*gh)) { + if (length < sizeof(*gh)) { LOGP(DMSC, LOGL_ERROR, "GSM48 header does not fit.\n"); return -1; } gh = (struct gsm48_hdr *) msgb_l3(msg); + length -= (const char *)&gh->data[0] - (const char *)gh; + mtype = gh->msg_type & 0xbf; net = conn->bts->network; msc = conn->sccp_con->msc; @@ -285,6 +339,8 @@ int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) if (conn->sccp_con->new_subscriber) return send_welcome_ussd(conn); return 0; + } else if (mtype == GSM48_MT_MM_INFO) { + bsc_patch_mm_info(conn, &gh->data[0], length); } return 0; diff --git a/openbsc/tests/Makefile.am b/openbsc/tests/Makefile.am index f2dc057..ed21fc3 100644 --- a/openbsc/tests/Makefile.am +++ b/openbsc/tests/Makefile.am @@ -4,6 +4,10 @@ if BUILD_NAT SUBDIRS += bsc-nat bsc-nat-trie endif +if BUILD_BSC +SUBDIRS += bsc +endif + if BUILD_SMPP SUBDIRS += smpp endif diff --git a/openbsc/tests/atlocal.in b/openbsc/tests/atlocal.in index bfbecd4..4635113 100644 --- a/openbsc/tests/atlocal.in +++ b/openbsc/tests/atlocal.in @@ -1,2 +1,3 @@ enable_nat_test='@osmo_ac_build_nat@' enable_smpp_test='@osmo_ac_build_smpp@' +enable_bsc_test='@osmo_ac_build_bsc@' diff --git a/openbsc/tests/bsc/Makefile.am b/openbsc/tests/bsc/Makefile.am new file mode 100644 index 0000000..202ba73 --- /dev/null +++ b/openbsc/tests/bsc/Makefile.am @@ -0,0 +1,19 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) +AM_LDFLAGS = $(COVERAGE_LDFLAGS) + +EXTRA_DIST = bsc_test.ok + +noinst_PROGRAMS = bsc_test + +bsc_test_SOURCES = bsc_test.c \ + $(top_srcdir)/src/osmo-bsc/osmo_bsc_filter.c +bsc_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ + $(top_srcdir)/src/libmsc/libmsc.a \ + $(top_srcdir)/src/libctrl/libctrl.a \ + $(top_srcdir)/src/libmgcp/libmgcp.a \ + $(top_srcdir)/src/libtrau/libtrau.a \ + $(top_srcdir)/src/libcommon/libcommon.a \ + $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) -lrt \ + $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) \ + $(LIBOSMOABIS_LIBS) diff --git a/openbsc/tests/bsc/bsc_test.c b/openbsc/tests/bsc/bsc_test.c new file mode 100644 index 0000000..1a089ae --- /dev/null +++ b/openbsc/tests/bsc/bsc_test.c @@ -0,0 +1,193 @@ +/* + * BSC Message filtering + * + * (C) 2013 by Jacob Erlbeck + * (C) 2010-2013 by Holger Hans Peter Freyther + * (C) 2010-2013 by On-Waves + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +enum test { + TEST_SCAN_TO_BTS, + TEST_SCAN_TO_MSC, +}; + +/* GSM 04.08 MM INFORMATION test message */ +static uint8_t gsm48_mm_info_nn_tzt[] = { + 0x05, 0x32, 0x45, 0x08, 0x80, 0x4f, 0x77, 0xeb, + 0x1a, 0xb6, 0x97, 0xe7, 0x47, 0x31, 0x90, 0x61, + 0x11, 0x02, 0x73, 0x00, +}; + +static uint8_t gsm48_mm_info_nn_tzt_out[] = { + 0x05, 0x32, 0x45, 0x08, 0x80, 0x4f, 0x77, 0xeb, + 0x1a, 0xb6, 0x97, 0xe7, 0x47, 0x31, 0x90, 0x61, + 0x11, 0x02, 0x73, 0x1a, +}; + +static uint8_t gsm48_mm_info_nn_tzt_dst[] = { + 0x05, 0x32, 0x45, 0x08, 0x80, 0x4f, 0x77, 0xeb, + 0x1a, 0xb6, 0x97, 0xe7, 0x47, 0x31, 0x90, 0x61, + 0x11, 0x02, 0x73, 0x00, 0x49, 0x01, 0x00, +}; + +static uint8_t gsm48_mm_info_nn_tzt_dst_out[] = { + 0x05, 0x32, 0x45, 0x08, 0x80, 0x4f, 0x77, 0xeb, + 0x1a, 0xb6, 0x97, 0xe7, 0x47, 0x31, 0x90, 0x61, + 0x11, 0x02, 0x73, 0x1a, 0x49, 0x01, 0x02, +}; + +struct test_definition { + const uint8_t *data; + const uint16_t length; + const int dir; + const int result; + const uint8_t *out_data; + const uint16_t out_length; + const char* params; + const int n_params; +}; + +static int get_int(const char *params, size_t nmemb, const char *key, int def, int *is_set) +{ + const char *kv = NULL; + + kv = strstr(params, key); + if (kv) { + kv += strlen(key) + 1; + fprintf(stderr, "get_int(%s) -> %d\n", key, atoi(kv)); + if (is_set) + *is_set = 1; + } + + return kv ? atoi(kv) : def; +} + +static const struct test_definition test_scan_defs[] = { + { + .data = gsm48_mm_info_nn_tzt_dst, + .length = ARRAY_SIZE(gsm48_mm_info_nn_tzt), + .dir = TEST_SCAN_TO_BTS, + .result = 0, + .out_data = gsm48_mm_info_nn_tzt_dst_out, + .out_length = ARRAY_SIZE(gsm48_mm_info_nn_tzt_out), + .params = "tz_hr=-5 tz_mn=15 tz_dst=2", + .n_params = 3, + }, + { + .data = gsm48_mm_info_nn_tzt_dst, + .length = ARRAY_SIZE(gsm48_mm_info_nn_tzt_dst), + .dir = TEST_SCAN_TO_BTS, + .result = 0, + .out_data = gsm48_mm_info_nn_tzt_dst_out, + .out_length = ARRAY_SIZE(gsm48_mm_info_nn_tzt_dst_out), + .params = "tz_hr=-5 tz_mn=15 tz_dst=2", + .n_params = 3, + }, +}; + +static void test_scan(void) +{ + void *text_ctx = talloc_named_const(NULL, 1, "testbsc"); + int i; + + struct gsm_network *net = talloc_zero(text_ctx, struct gsm_network); + struct gsm_bts *bts = talloc_zero(text_ctx, struct gsm_bts); + struct osmo_bsc_sccp_con *sccp_con = talloc_zero(text_ctx, struct osmo_bsc_sccp_con); + struct osmo_msc_data *msc = talloc_zero(text_ctx, struct osmo_msc_data); + struct gsm_subscriber_connection *conn = talloc_zero(text_ctx, struct gsm_subscriber_connection); + + bts->network = net; + sccp_con->msc = msc; + conn->bts = bts; + conn->sccp_con = sccp_con; + + /* start testinh with proper messages */ + printf("Testing BTS<->MSC message scan.\n"); + for (i = 0; i < ARRAY_SIZE(test_scan_defs); ++i) { + const struct test_definition *test_def = &test_scan_defs[i]; + int result; + struct msgb *msg = msgb_alloc(4096, "test-message"); + int is_set = 0; + + bts->tz.hr = get_int(test_def->params, test_def->n_params, "tz_hr", 0, &is_set); + bts->tz.mn = get_int(test_def->params, test_def->n_params, "tz_mn", 0, &is_set); + bts->tz.dst = get_int(test_def->params, test_def->n_params, "tz_dst", 0, &is_set); + bts->tz.override = get_int(test_def->params, test_def->n_params, "tz_dst", is_set ? 1 : 0, NULL); + + printf("Going to test item: %d\n", i); + msg->l3h = msgb_put(msg, test_def->length); + memcpy(msg->l3h, test_def->data, test_def->length); + + switch (test_def->dir) { + case TEST_SCAN_TO_BTS: + result = bsc_scan_msc_msg(conn, msg); + break; + case TEST_SCAN_TO_MSC: + result = bsc_scan_msc_msg(conn, msg); + break; + } + + if (result != test_def->result) { + printf("FAIL: Not the expected result, got: %d wanted: %d\n", + result, test_def->result); + goto out; + } + + if (msgb_l3len(msg) != test_def->out_length) { + printf("FAIL: Not the expected message size, got: %d wanted: %d\n", + msgb_l3len(msg), test_def->out_length); + goto out; + } + + if (memcmp(msgb_l3(msg), test_def->out_data, test_def->out_length) != 0) { + printf("FAIL: Not the expected message\n"); + goto out; + } + +out: + msgb_free(msg); + } +} + + +int main(int argc, char **argv) +{ + osmo_init_logging(&log_info); + + test_scan(); + + printf("Testing execution completed.\n"); + return 0; +} diff --git a/openbsc/tests/bsc/bsc_test.ok b/openbsc/tests/bsc/bsc_test.ok new file mode 100644 index 0000000..0564bf0 --- /dev/null +++ b/openbsc/tests/bsc/bsc_test.ok @@ -0,0 +1,4 @@ +Testing BTS<->MSC message scan. +Going to test item: 0 +Going to test item: 1 +Testing execution completed. diff --git a/openbsc/tests/testsuite.at b/openbsc/tests/testsuite.at index e54d4b5..240f5e2 100644 --- a/openbsc/tests/testsuite.at +++ b/openbsc/tests/testsuite.at @@ -68,3 +68,11 @@ AT_KEYWORDS([abis]) cat $abs_srcdir/abis/abis_test.ok > expout AT_CHECK([$abs_top_builddir/tests/abis/abis_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([bsc]) +AT_KEYWORDS([bsc]) +AT_CHECK([test "$enable_bsc_test" != no || exit 77]) +cat $abs_srcdir/bsc/bsc_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/bsc/bsc_test], [], [expout], [ignore]) +AT_CLEANUP + diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 7f71288..c0ba57d 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -280,6 +280,40 @@ class TestVTYBSC(TestVTYGenericBSC): self.assertEquals(res.find('missing-msc-text No MSC found'), -1) self.assert_(res.find('no missing-msc-text') > 0) + def testNetworkTimezone(self): + self.vty.enable() + self.vty.verify("configure terminal", ['']) + self.vty.verify("network", ['']) + self.vty.verify("bts 0", ['']) + + # Test invalid input + self.vty.verify("timezone", ['% Command incomplete.']) + self.vty.verify("timezone 20 0", ['% Unknown command.']) + self.vty.verify("timezone 0 11", ['% Unknown command.']) + self.vty.verify("timezone 0 0 99", ['% Unknown command.']) + + # Set time zone without DST + self.vty.verify("timezone 2 30", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('timezone 2 30') > 0) + self.assertEquals(res.find('timezone 2 30 '), -1) + + # Set time zone with DST + self.vty.verify("timezone 2 30 1", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('timezone 2 30 1') > 0) + + # Now disable it.. + self.vty.verify("no timezone", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assertEquals(res.find(' timezone'), -1) + class TestVTYNAT(TestVTYGenericBSC): def vty_command(self): -- 1.7.9.5 From holger at freyther.de Wed Sep 18 14:30:25 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 18 Sep 2013 16:30:25 +0200 Subject: [PATCH] bsc/mminfo: Patch timezone and DST in MM Info messages In-Reply-To: <1379419169-17036-1-git-send-email-jerlbeck@sysmocom.de> References: <1379335814-7416-1-git-send-email-jerlbeck@sysmocom.de> <1379419169-17036-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130918143025.GB9120@xiaoyu.lan> On Tue, Sep 17, 2013 at 01:59:29PM +0200, Jacob Erlbeck wrote: Good Afternoon Jacob! > + if (bts->tz.override) { if (!bts->tz.override) return 0; do you mind if I change the code to be like that? > + /* Convert tz.hr and tz.mn to units */ this could be a routine by itself (but not for now)? I didn't read the spec so I don't understand this calculation. :) > + if (TLVP_PRESENT(&tp, GSM48_IE_UTC)) { > + LOGP(DMSC, LOGL_DEBUG, "Changing 'Local time zone' from 0x%02x to 0x%02x.\n", TLVP_VAL(&tp, GSM48_IE_UTC)[6], tzbsd); we aim for line width of 80 chars. E.g. break after LOGL_DEBUG and after the format string. > + * (C) 2013 by Jacob Erlbeck Copyright is with sysmocom s.f.m.c. GmbH, you are the author and deserve credit for the code. I think something like the below is approriate: (C) 2013 by sysmocom s.f.m.c. GmbH Written by Jacob Erlbeck > +static uint8_t gsm48_mm_info_nn_tzt[] = { > + 0x05, 0x32, 0x45, 0x08, 0x80, 0x4f, 0x77, 0xeb, > + 0x1a, 0xb6, 0x97, 0xe7, 0x47, 0x31, 0x90, 0x61, > + 0x11, 0x02, 0x73, 0x00, I will remove the leading whitespace here. :) > + struct gsm_network *net = talloc_zero(text_ctx, struct gsm_network); > + struct gsm_bts *bts = talloc_zero(text_ctx, struct gsm_bts); > + struct osmo_bsc_sccp_con *sccp_con = talloc_zero(text_ctx, struct osmo_bsc_sccp_con); > + struct osmo_msc_data *msc = talloc_zero(text_ctx, struct osmo_msc_data); > + struct gsm_subscriber_connection *conn = talloc_zero(text_ctx, struct gsm_subscriber_connection); if you put bts, sccp_con, msc and conn into the net context you can do a talloc_free(net) and all the others will be freed. This way we can run the test with valgrinds leak-check and get less output. :) thank you very much for the change. I can make the modifications if you agree in principle. holger From vasil_vel at abv.bg Wed Sep 18 17:04:26 2013 From: vasil_vel at abv.bg (Vasil Velichckov) Date: Wed, 18 Sep 2013 20:04:26 +0300 Subject: [PATCH 0/3] Build libosmo-sccp shared objects. Message-ID: <1379523869-17555-1-git-send-email-vasil_vel@abv.bg> Hi, While I was playing around with openbsc project I noticed that the libosmo-sccp libraries are built as a static libraries only and I decided that it will be useful to build them as shared objects too. I also enabled colored output of the test suite and ignore all tag files that are generated by the Makefiles. Cheers Vasil Velichckov (3): Build shared objects with libtool Enable colored test results by default Ignore the tag files that are generated by Makefile .gitignore | 9 +++++++++ configure.ac | 2 +- src/Makefile.am | 18 +++++++++++++----- tests/m2ua/Makefile.am | 2 +- tests/sccp/Makefile.am | 4 ++-- tests/testsuite.at | 1 + 6 files changed, 27 insertions(+), 9 deletions(-) -- 1.7.10.4 From vasil_vel at abv.bg Wed Sep 18 17:04:27 2013 From: vasil_vel at abv.bg (Vasil Velichckov) Date: Wed, 18 Sep 2013 20:04:27 +0300 Subject: [PATCH 1/3] Build shared objects with libtool In-Reply-To: <1379523869-17555-1-git-send-email-vasil_vel@abv.bg> References: <1379523869-17555-1-git-send-email-vasil_vel@abv.bg> Message-ID: <1379523869-17555-2-git-send-email-vasil_vel@abv.bg> Convert static libraries to shared objects. Link the test programs to the shared objects --- .gitignore | 5 +++++ configure.ac | 2 +- src/Makefile.am | 18 +++++++++++++----- tests/m2ua/Makefile.am | 2 +- tests/sccp/Makefile.am | 4 ++-- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 65fb1ef..1bb2d00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ *.o *.a +*.la +*.lo .deps +.libs Makefile Makefile.in bscconfig.h @@ -23,6 +26,8 @@ depcomp install-sh missing stamp-h1 +libtool +ltmain.sh # git-version-gen magic .tarball-version diff --git a/configure.ac b/configure.ac index 98a6b1f..9dea792 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ dnl checks for programs AC_PROG_MAKE_SET AC_PROG_CC AC_PROG_INSTALL -AC_PROG_RANLIB +LT_INIT PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.3.0) diff --git a/src/Makefile.am b/src/Makefile.am index 584c3bd..0c29085 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,9 +1,17 @@ +# This is _NOT_ the library release version, it's an API version. +# Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification +LIBVERSION=1:0:0 + AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) -sccpdir = $(libdir) -sccp_LIBRARIES = libsccp.a libmtp.a libm2ua.a +lib_LTLIBRARIES = libsccp.la libmtp.la libm2ua.la + +libsccp_la_SOURCES = sccp.c +libsccp_la_LDFLAGS = -version-info $(LIBVERSION) $(LIBOSMOCORE_LDFLAGS) -no-undefined + +libmtp_la_SOURCES = mtp_pcap.c +libmtp_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined -libsccp_a_SOURCES = sccp.c -libmtp_a_SOURCES = mtp_pcap.c -libm2ua_a_SOURCES = m2ua_msg.c +libm2ua_la_SOURCES = m2ua_msg.c +libm2ua_la_LDFLAGS = -version-info $(LIBVERSION) $(LIBOSMOCORE_LDFLAGS) -no-undefined diff --git a/tests/m2ua/Makefile.am b/tests/m2ua/Makefile.am index 7299e9b..128fc68 100644 --- a/tests/m2ua/Makefile.am +++ b/tests/m2ua/Makefile.am @@ -5,4 +5,4 @@ EXTRA_DIST = m2ua_test.ok noinst_PROGRAMS = m2ua_test m2ua_test_SOURCES = m2ua_test.c -m2ua_test_LDADD = $(top_builddir)/src/libm2ua.a $(LIBOSMOCORE_LIBS) +m2ua_test_LDADD = $(top_builddir)/src/libm2ua.la $(LIBOSMOCORE_LIBS) diff --git a/tests/sccp/Makefile.am b/tests/sccp/Makefile.am index 8cce20c..7c4cb20 100644 --- a/tests/sccp/Makefile.am +++ b/tests/sccp/Makefile.am @@ -5,6 +5,6 @@ EXTRA_DIST = sccp_test.ok noinst_PROGRAMS = sccp_test -sccp_test_SOURCES = sccp_test.c $(top_srcdir)/src/sccp.c -sccp_test_LDADD = $(LIBOSMOCORE_LIBS) +sccp_test_SOURCES = sccp_test.c +sccp_test_LDADD = $(top_builddir)/src/libsccp.la $(LIBOSMOCORE_LIBS) -- 1.7.10.4 From vasil_vel at abv.bg Wed Sep 18 17:04:28 2013 From: vasil_vel at abv.bg (Vasil Velichckov) Date: Wed, 18 Sep 2013 20:04:28 +0300 Subject: [PATCH 2/3] Enable colored test results by default In-Reply-To: <1379523869-17555-1-git-send-email-vasil_vel@abv.bg> References: <1379523869-17555-1-git-send-email-vasil_vel@abv.bg> Message-ID: <1379523869-17555-3-git-send-email-vasil_vel@abv.bg> --- tests/testsuite.at | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testsuite.at b/tests/testsuite.at index 8907ffa..d040907 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -1,5 +1,6 @@ AT_INIT AT_BANNER([Regression tests.]) +AT_COLOR_TESTS AT_SETUP([m2ua]) AT_KEYWORDS([m2ua]) -- 1.7.10.4 From vasil_vel at abv.bg Wed Sep 18 17:04:29 2013 From: vasil_vel at abv.bg (Vasil Velichckov) Date: Wed, 18 Sep 2013 20:04:29 +0300 Subject: [PATCH 3/3] Ignore the tag files that are generated by Makefile In-Reply-To: <1379523869-17555-1-git-send-email-vasil_vel@abv.bg> References: <1379523869-17555-1-git-send-email-vasil_vel@abv.bg> Message-ID: <1379523869-17555-4-git-send-email-vasil_vel@abv.bg> Tag files are generated by Makefile tags and ctags targets make tags make ctags --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 1bb2d00..8196f74 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,7 @@ tests/testsuite.log *.pc config.* + +# Tag files +tags +TAGS -- 1.7.10.4 From jolly at eversberg.eu Thu Sep 19 12:11:46 2013 From: jolly at eversberg.eu (Andreas Eversberg) Date: Thu, 19 Sep 2013 14:11:46 +0200 Subject: [PATCH 01/20] sysmo-bts: Use correct boundaries of L1 msg when forwarding to L1 proxy Message-ID: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> In case of a headroom in a message, the 'head' pointer will not point to the actual data. --- src/osmo-bts-sysmo/l1_transp_fwd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osmo-bts-sysmo/l1_transp_fwd.c b/src/osmo-bts-sysmo/l1_transp_fwd.c index 5050705..87c230b 100644 --- a/src/osmo-bts-sysmo/l1_transp_fwd.c +++ b/src/osmo-bts-sysmo/l1_transp_fwd.c @@ -95,7 +95,7 @@ static int fwd_read_cb(struct osmo_fd *ofd) static int prim_write_cb(struct osmo_fd *ofd, struct msgb *msg) { /* write to the fd */ - return write(ofd->fd, msg->head, msg->len); + return write(ofd->fd, msg->l1h, msgb_l1len(msg)); } int l1if_transport_open(int q, struct femtol1_hdl *fl1h) -- 1.8.1.5 From jolly at eversberg.eu Thu Sep 19 12:11:47 2013 From: jolly at eversberg.eu (Andreas Eversberg) Date: Thu, 19 Sep 2013 14:11:47 +0200 Subject: [PATCH 02/20] Add header file of PH-/MPH-/TCH-SAP interface to common part of osmo-bts In-Reply-To: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> References: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> Message-ID: <1379592710-4811-2-git-send-email-jolly@eversberg.eu> Instead of handling primitives directly at layer 1 specific code, osmo-bts handles primitives at common code. When all primitive are moved, the l1sap interface will: - receive PH-DATA indications and forward them to layer 2. - check for RF link loss and notify BSC. - receive TCH indications and forward them via RTP. - receive PH-RTS indications and send PH-DATA requests with content according to its logical channel. - receive TCH-RTS indications and send TCH requests with content received via RTP or loopback from TCH indications. - send MPH-INFO requests to activate, deactivate and modify logical channels and handle their confirms. - receive MPH-INFO indications with measurements from tranceiver. - forward received and transmitted PH-DATA to GSMTAP. --- include/osmo-bts/Makefile.am | 3 +- include/osmo-bts/l1sap.h | 71 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 include/osmo-bts/l1sap.h diff --git a/include/osmo-bts/Makefile.am b/include/osmo-bts/Makefile.am index 456d416..d8c0002 100644 --- a/include/osmo-bts/Makefile.am +++ b/include/osmo-bts/Makefile.am @@ -1,2 +1,3 @@ noinst_HEADERS = abis.h bts.h bts_model.h gsm_data.h logging.h measurement.h \ - oml.h paging.h rsl.h signal.h vty.h amr.h pcu_if.h pcuif_proto.h + oml.h paging.h rsl.h signal.h vty.h amr.h pcu_if.h \ + pcuif_proto.h l1sap.h diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h new file mode 100644 index 0000000..a1dc303 --- /dev/null +++ b/include/osmo-bts/l1sap.h @@ -0,0 +1,71 @@ +#ifndef L1SAP_H +#define L1SAP_H + +/* timeslot and subslot from chan_nr */ +#define L1SAP_CHAN2TS(chan_nr) (chan_nr & 7) +#define L1SAP_CHAN2SS_TCHH(chan_nr) ((chan_nr >> 3) & 1) +#define L1SAP_CHAN2SS_SDCCH4(chan_nr) ((chan_nr >> 3) & 3) +#define L1SAP_CHAN2SS_SDCCH8(chan_nr) ((chan_nr >> 3) & 7) + +/* logical channel from chan_nr + link_id */ +#define L1SAP_IS_LINK_SACCH(link_id) ((link_id & 0xC0) == 0x40) +#define L1SAP_IS_CHAN_TCHF(chan_nr) ((chan_nr & 0xf8) == 0x08) +#define L1SAP_IS_CHAN_TCHH(chan_nr) ((chan_nr & 0xf0) == 0x10) +#define L1SAP_IS_CHAN_SDCCH4(chan_nr) ((chan_nr & 0xe0) == 0x20) +#define L1SAP_IS_CHAN_SDCCH8(chan_nr) ((chan_nr & 0xc0) == 0x40) +#define L1SAP_IS_CHAN_BCCH(chan_nr) ((chan_nr & 0xf8) == 0x80) +#define L1SAP_IS_CHAN_RACH(chan_nr) ((chan_nr & 0xf8) == 0x88) +#define L1SAP_IS_CHAN_AGCH_PCH(chan_nr) ((chan_nr & 0xf8) == 0x90) + +/* rach type from ra */ +#define L1SAP_IS_PACKET_RACH(ra) ((ra & 0xf0) == 0x70) + +/* CCCH block from frame number */ +#define L1SAP_FN2CCCHBLOCK(fn) ((fn % 51) / 5 - 1) + +/* PTCH layout from frame number */ +#define L1SAP_FN2MACBLOCK(fn) ((fn % 52) / 4) +#define L1SAP_FN2PTCCHBLOCK(fn) ((fn / 52) & 7) +#define L1SAP_IS_PTCCH(fn) ((fn % 52) == 12) + +/* subslot from any chan_nr */ +static inline uint8_t l1sap_chan2ss(uint8_t chan_nr) +{ + if (L1SAP_IS_CHAN_SDCCH8(chan_nr)) + return L1SAP_CHAN2SS_SDCCH8(chan_nr); + if (L1SAP_IS_CHAN_SDCCH4(chan_nr)) + return L1SAP_CHAN2SS_SDCCH4(chan_nr); + if (L1SAP_IS_CHAN_TCHH(chan_nr)) + return L1SAP_CHAN2SS_TCHH(chan_nr); + return 0; +} + + +/* allocate a msgb containing a osmo_phsap_prim + optional l2 data */ +struct msgb *l1sap_msgb_alloc(unsigned int l2_len); + +/* any L1 prim received from bts model */ +int l1sap_up(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap); + +/* pcu (socket interface) sends us a data request primitive */ +int l1sap_pdch_req(struct gsm_bts_trx_ts *ts, int is_ptcch, uint32_t fn, + uint16_t arfcn, uint8_t block_nr, uint8_t *data, uint8_t len); + +/* call-back function for incoming RTP */ +void l1sap_rtp_rx_cb(struct osmo_rtp_socket *rs, const uint8_t *rtp_pl, + unsigned int rtp_pl_len); + +/* channel control */ +int l1sap_chan_act(struct gsm_bts_trx *trx, uint8_t chan_nr); +int l1sap_chan_rel(struct gsm_bts_trx *trx, uint8_t chan_nr); +int l1sap_chan_deact_sacch(struct gsm_bts_trx *trx, uint8_t chan_nr); +int l1sap_chan_modify(struct gsm_bts_trx *trx, uint8_t chan_nr); + +extern const struct value_string gsmtap_sapi_names[]; +extern struct gsmtap_inst *gsmtap; +extern uint32_t gsmtap_sapi_mask; +extern uint8_t gsmtap_sapi_acch; + +#define msgb_l1sap_prim(msg) ((struct osmo_phsap_prim *)(msg)->l1h) + +#endif /* L1SAP_H */ -- 1.8.1.5 From jolly at eversberg.eu Thu Sep 19 12:11:48 2013 From: jolly at eversberg.eu (Andreas Eversberg) Date: Thu, 19 Sep 2013 14:11:48 +0200 Subject: [PATCH 03/20] Add BCCH message to PH-/MPH-/TCH-SAP interface In-Reply-To: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> References: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> Message-ID: <1379592710-4811-3-git-send-email-jolly@eversberg.eu> This first part moves BCCH message primitives from osmo-bts-sysmo to common part. A new file "common/l1sap.c" is introduced to implement handling of layer 1 messages from/to BTS model. --- include/osmo-bts/bts_model.h | 2 + src/common/Makefile.am | 2 +- src/common/l1sap.c | 150 ++++++++++++++++++++++++++++++++++++++ src/osmo-bts-sysmo/l1_if.c | 167 +++++++++++++++++++++++++++++++++++++++---- tests/stubs.c | 2 + 5 files changed, 310 insertions(+), 13 deletions(-) create mode 100644 src/common/l1sap.c diff --git a/include/osmo-bts/bts_model.h b/include/osmo-bts/bts_model.h index bfa6bd8..f6545cc 100644 --- a/include/osmo-bts/bts_model.h +++ b/include/osmo-bts/bts_model.h @@ -43,4 +43,6 @@ int bts_model_vty_init(struct gsm_bts *bts); void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts); void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx); +int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap); + #endif diff --git a/src/common/Makefile.am b/src/common/Makefile.am index b2f6f8e..1c6ff9e 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -5,4 +5,4 @@ LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOTRAU_LIBS) noinst_LIBRARIES = libbts.a libbts_a_SOURCES = gsm_data_shared.c sysinfo.c logging.c abis.c oml.c bts.c \ rsl.c vty.c paging.c measurement.c amr.c lchan.c \ - load_indication.c pcu_sock.c + load_indication.c pcu_sock.c l1sap.c diff --git a/src/common/l1sap.c b/src/common/l1sap.c new file mode 100644 index 0000000..f4f3246 --- /dev/null +++ b/src/common/l1sap.c @@ -0,0 +1,150 @@ +/* L1 SAP primitives */ + +/* (C) 2011 by Harald Welte + * (C) 2013 by Andreas Eversberg + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +static int l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap); + +static const uint8_t fill_frame[GSM_MACBLOCK_LEN] = { + 0x03, 0x03, 0x01, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, + 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, + 0x2B, 0x2B, 0x2B +}; + +/* allocate a msgb containing a osmo_phsap_prim + optional l2 data + * in order to wrap femtobts header arround l2 data, there must be enough space + * in front and behind data pointer */ +struct msgb *l1sap_msgb_alloc(unsigned int l2_len) +{ + struct msgb *msg = msgb_alloc_headroom(512, 128, "l1sap_prim"); + + if (!msg) + return NULL; + + msg->l1h = msgb_put(msg, sizeof(struct osmo_phsap_prim)); + + return msg; +} + +/* PH-RTS-IND prim recevied from bts model */ +static int l1sap_ph_rts_ind(struct gsm_bts_trx *trx, + struct osmo_phsap_prim *l1sap, struct ph_data_param *rts_ind) +{ + struct msgb *msg = l1sap->oph.msg; + struct gsm_time g_time; + uint8_t chan_nr, link_id; + uint8_t tn; + uint32_t fn; + uint8_t *p, *si; + + chan_nr = rts_ind->chan_nr; + link_id = rts_ind->link_id; + fn = rts_ind->fn; + tn = L1SAP_CHAN2TS(chan_nr); + + gsm_fn2gsmtime(&g_time, fn); + + DEBUGP(DL1P, "Rx PH-RTS.ind %02u/%02u/%02u chan_nr=%d link_id=%d\n", + g_time.t1, g_time.t2, g_time.t3, chan_nr, link_id); + + /* reuse PH-RTS.ind for PH-DATA.req */ + if (!msg) { + LOGP(DL1P, LOGL_FATAL, "RTS without msg to be reused. Please " + "fix!\n"); + abort(); + } + msgb_trim(msg, sizeof(*l1sap)); + osmo_prim_init(&l1sap->oph, SAP_GSM_PH, PRIM_PH_DATA, PRIM_OP_REQUEST, + msg); + msg->l2h = msg->l1h + sizeof(*l1sap); + + if (L1SAP_IS_CHAN_BCCH(chan_nr)) { + p = msgb_put(msg, GSM_MACBLOCK_LEN); + /* get them from bts->si_buf[] */ + si = bts_sysinfo_get(trx->bts, &g_time); + if (si) + memcpy(p, si, GSM_MACBLOCK_LEN); + else + memcpy(p, fill_frame, GSM_MACBLOCK_LEN); + } + + DEBUGP(DL1P, "Tx PH-DATA.req %02u/%02u/%02u chan_nr=%d link_id=%d\n", + g_time.t1, g_time.t2, g_time.t3, chan_nr, link_id); + + l1sap_down(trx, l1sap); + + /* don't free, because we forwarded data */ + return 1; +} + +/* any L1 prim received from bts model */ +int l1sap_up(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap) +{ + struct msgb *msg = l1sap->oph.msg; + int rc = 0; + + switch (OSMO_PRIM_HDR(&l1sap->oph)) { + case OSMO_PRIM(PRIM_PH_RTS, PRIM_OP_INDICATION): + rc = l1sap_ph_rts_ind(trx, l1sap, &l1sap->u.data); + break; + default: + LOGP(DL1P, LOGL_NOTICE, "unknown prim %d op %d\n", + l1sap->oph.primitive, l1sap->oph.operation); + break; + } + + /* Special return value '1' means: do not free */ + if (rc != 1) + msgb_free(msg); + + return rc; +} + +/* any L1 prim sent to bts model */ +static int l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap) +{ + return bts_model_l1sap_down(trx, l1sap); +} + diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index e16bb49..93b4de7 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -366,8 +367,135 @@ static const uint8_t fill_frame[GSM_MACBLOCK_LEN] = { 0x2B, 0x2B, 0x2B }; +static int ph_data_req(struct gsm_bts_trx *trx, struct msgb *msg, + struct osmo_phsap_prim *l1sap) +{ + struct femtol1_hdl *fl1 = trx_femtol1_hdl(trx); + uint32_t u32Fn; + uint8_t u8Tn, subCh, u8BlockNbr = 0, sapi; + uint8_t chan_nr, link_id; + GsmL1_Prim_t *l1p; + int len; + + if (!msg) { + LOGP(DL1C, LOGL_FATAL, "PH-DATA.req without msg. " + "Please fix!\n"); + abort(); + } + chan_nr = l1sap->u.data.chan_nr; + link_id = l1sap->u.data.link_id; + u32Fn = l1sap->u.data.fn; + u8Tn = L1SAP_CHAN2TS(chan_nr); + subCh = 0x1f; + if (L1SAP_IS_CHAN_BCCH(chan_nr)) { + sapi = GsmL1_Sapi_Bcch; + } else { + LOGP(DL1C, LOGL_NOTICE, "unknown prim %d op %d " + "chan_nr %d link_id %d\n", l1sap->oph.primitive, + l1sap->oph.operation, chan_nr, link_id); + return -EINVAL; + } + + /* pull and trim msg to start of payload */ + msgb_pull(msg, sizeof(*l1sap)); + len = msg->len; + msgb_trim(msg, 0); + + /* convert l1sap message to GsmL1 primitive, keep payload */ + if (len) { + /* data request */ + GsmL1_PhDataReq_t *data_req; + GsmL1_MsgUnitParam_t *msu_param; + uint8_t *temp; + + /* wrap zeroed l1p structure arrount payload + * this must be done in three steps, since the actual + * payload is not at the end but inside the l1p structure. */ + temp = l1p->u.phDataReq.msgUnitParam.u8Buffer; + msgb_push(msg, temp - (uint8_t *)l1p); + memset(msg->data, 0, msg->len); + msgb_put(msg, len); + memset(msg->tail, 0, sizeof(*l1p) - msg->len); + msgb_put(msg, sizeof(*l1p) - msg->len); + msg->l1h = msg->data; + + l1p = msgb_l1prim(msg); + l1p->id = GsmL1_PrimId_PhDataReq; + data_req = &l1p->u.phDataReq; + data_req->hLayer1 = fl1->hLayer1; + data_req->u8Tn = u8Tn; + data_req->u32Fn = u32Fn; + data_req->sapi = sapi; + data_req->subCh = subCh; + data_req->u8BlockNbr = u8BlockNbr; + msu_param = &data_req->msgUnitParam; + msu_param->u8Size = len; + } else { + /* empty frame */ + GsmL1_PhEmptyFrameReq_t *empty_req; + + /* put l1p structure */ + msgb_put(msg, sizeof(*l1p)); + memset(msg->data, 0, msg->len); + msg->l1h = msg->data; + + l1p = msgb_l1prim(msg); + l1p->id = GsmL1_PrimId_PhEmptyFrameReq; + empty_req = &l1p->u.phEmptyFrameReq; + empty_req->hLayer1 = fl1->hLayer1; + empty_req->u8Tn = u8Tn; + empty_req->u32Fn = u32Fn; + empty_req->sapi = sapi; + empty_req->subCh = subCh; + empty_req->u8BlockNbr = u8BlockNbr; + } + + /* send message to DSP's queue */ + osmo_wqueue_enqueue(&fl1->write_q[MQ_L1_WRITE], msg); + + return 0; +} + +/* primitive from common part */ +int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap) +{ + struct msgb *msg = l1sap->oph.msg; + int rc = 0; + + switch (OSMO_PRIM_HDR(&l1sap->oph)) { + case OSMO_PRIM(PRIM_PH_DATA, PRIM_OP_REQUEST): + rc = ph_data_req(trx, msg, l1sap); + break; + default: + LOGP(DL1C, LOGL_NOTICE, "unknown prim %d op %d\n", + l1sap->oph.primitive, l1sap->oph.operation); + rc = -EINVAL; + } + + if (rc) + msgb_free(msg); + return rc; +} + +static uint8_t chan_nr_by_sapi(enum gsm_phys_chan_config pchan, + GsmL1_Sapi_t sapi, GsmL1_SubCh_t subCh, + uint8_t u8Tn, uint32_t u32Fn) +{ + uint8_t cbits = 0; + switch (sapi) { + case GsmL1_Sapi_Bcch: + cbits = 0x10; + break; + default: + return 0; + } + + return (cbits << 3) | u8Tn; +} + static int handle_ph_readytosend_ind(struct femtol1_hdl *fl1, - GsmL1_PhReadyToSendInd_t *rts_ind) + GsmL1_PhReadyToSendInd_t *rts_ind, + struct msgb *l1p_msg) { struct gsm_bts_trx *trx = fl1->priv; struct gsm_bts *bts = trx->bts; @@ -379,9 +507,31 @@ static int handle_ph_readytosend_ind(struct femtol1_hdl *fl1, struct gsm_lchan *lchan; struct gsm_time g_time; uint32_t t3p; - uint8_t *si; struct osmo_phsap_prim pp; int rc; + struct osmo_phsap_prim *l1sap; + uint8_t chan_nr, link_id; + uint32_t fn; + + + /* check if primitive should be handled by common part */ + chan_nr = chan_nr_by_sapi(trx->ts[rts_ind->u8Tn].pchan, rts_ind->sapi, + rts_ind->subCh, rts_ind->u8Tn, rts_ind->u32Fn); + if (chan_nr) { + fn = rts_ind->u32Fn; + link_id = 0; + rc = msgb_trim(l1p_msg, sizeof(*l1sap)); + if (rc < 0) + MSGB_ABORT(l1p_msg, "No room for primitive\n"); + l1sap = msgb_l1sap_prim(l1p_msg); + osmo_prim_init(&l1sap->oph, SAP_GSM_PH, PRIM_PH_RTS, + PRIM_OP_INDICATION, l1p_msg); + l1sap->u.data.link_id = link_id; + l1sap->u.data.chan_nr = chan_nr; + l1sap->u.data.fn = fn; + + return l1sap_up(trx, l1sap); + } gsm_fn2gsmtime(&g_time, rts_ind->u32Fn); @@ -460,14 +610,6 @@ static int handle_ph_readytosend_ind(struct femtol1_hdl *fl1, msu_param->u8Buffer[2] = (g_time.t1 << 7) | (g_time.t2 << 2) | (t3p >> 1); msu_param->u8Buffer[3] = (t3p & 1); break; - case GsmL1_Sapi_Bcch: - /* get them from bts->si_buf[] */ - si = bts_sysinfo_get(bts, &g_time); - if (si) - memcpy(msu_param->u8Buffer, si, GSM_MACBLOCK_LEN); - else - memcpy(msu_param->u8Buffer, fill_frame, GSM_MACBLOCK_LEN); - break; case GsmL1_Sapi_Sacch: /* resolve the L2 entity using rts_ind->hLayer2 */ lchan = l1if_hLayer_to_lchan(trx, rts_ind->hLayer2); @@ -555,6 +697,7 @@ tx: /* transmit */ osmo_wqueue_enqueue(&fl1->write_q[MQ_L1_WRITE], resp_msg); + msgb_free(l1p_msg); return 0; empty_frame: @@ -885,8 +1028,8 @@ static int l1if_handle_ind(struct femtol1_hdl *fl1, struct msgb *msg) case GsmL1_PrimId_PhConnectInd: break; case GsmL1_PrimId_PhReadyToSendInd: - rc = handle_ph_readytosend_ind(fl1, &l1p->u.phReadyToSendInd); - break; + return handle_ph_readytosend_ind(fl1, &l1p->u.phReadyToSendInd, + msg); case GsmL1_PrimId_PhDataInd: rc = handle_ph_data_ind(fl1, &l1p->u.phDataInd, msg); break; diff --git a/tests/stubs.c b/tests/stubs.c index c46bb4a..64b30c0 100644 --- a/tests/stubs.c +++ b/tests/stubs.c @@ -39,6 +39,8 @@ int bts_model_rsl_mode_modify(struct gsm_lchan *lchan) { return 0; } void bts_model_rtp_rx_cb(struct osmo_rtp_socket *rs, const uint8_t *rtp_pl, unsigned int rtp_pl_len) {} +int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap) +{ return 0; } int l1if_pdch_req(struct gsm_bts_trx_ts *ts, int is_ptcch, uint32_t fn, uint16_t arfcn, uint8_t block_nr, uint8_t *data, uint8_t len) -- 1.8.1.5 From jolly at eversberg.eu Thu Sep 19 12:11:49 2013 From: jolly at eversberg.eu (Andreas Eversberg) Date: Thu, 19 Sep 2013 14:11:49 +0200 Subject: [PATCH 04/20] Add RACH message to PH-/MPH-/TCH-SAP interface In-Reply-To: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> References: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> Message-ID: <1379592710-4811-4-git-send-email-jolly@eversberg.eu> This part moves RACH message primitives from osmo-bts-sysmo to common part. --- src/common/l1sap.c | 42 +++++++++++++++++++++++++++++++ src/osmo-bts-sysmo/l1_if.c | 61 +++++++++++++++++++++------------------------- 2 files changed, 70 insertions(+), 33 deletions(-) diff --git a/src/common/l1sap.c b/src/common/l1sap.c index f4f3246..996a589 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -119,6 +119,45 @@ static int l1sap_ph_rts_ind(struct gsm_bts_trx *trx, return 1; } +/* RACH received from bts model */ +static int l1sap_ph_rach_ind(struct gsm_bts_trx *trx, + struct osmo_phsap_prim *l1sap, struct ph_rach_ind_param *rach_ind) +{ + struct gsm_bts *bts = trx->bts; + struct gsm_bts_role_bts *btsb = bts->role; + struct lapdm_channel *lc; + + DEBUGP(DL1P, "Rx PH-RA.ind"); + + lc = &trx->ts[0].lchan[4].lapdm_ch; + if (!lc) { + LOGP(DL1P, LOGL_ERROR, "unable to resolve LAPD channel\n"); + return -ENODEV; + } + + /* check for under/overflow / sign */ + if (rach_ind->acc_delay > btsb->max_ta) { + LOGP(DL1P, LOGL_INFO, "ignoring RACH request %u > max_ta(%u)\n", + rach_ind->acc_delay, btsb->max_ta); + return 0; + } + + /* check for packet access */ + if (trx == bts->c0 + && L1SAP_IS_PACKET_RACH(rach_ind->ra)) { + LOGP(DL1P, LOGL_INFO, "RACH for packet access\n"); + pcu_tx_rach_ind(bts, rach_ind->acc_delay << 2, + rach_ind->ra, rach_ind->fn); + return 0; + } + + LOGP(DL1P, LOGL_INFO, "RACH for RR access (toa=%d, ra=%d)\n", + rach_ind->acc_delay, rach_ind->ra); + lapdm_phsap_up(&l1sap->oph, &lc->lapdm_dcch); + + return 0; +} + /* any L1 prim received from bts model */ int l1sap_up(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap) { @@ -129,6 +168,9 @@ int l1sap_up(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap) case OSMO_PRIM(PRIM_PH_RTS, PRIM_OP_INDICATION): rc = l1sap_ph_rts_ind(trx, l1sap, &l1sap->u.data); break; + case OSMO_PRIM(PRIM_PH_RACH, PRIM_OP_INDICATION): + rc = l1sap_ph_rach_ind(trx, l1sap, &l1sap->u.rach_ind); + break; default: LOGP(DL1P, LOGL_NOTICE, "unknown prim %d op %d\n", l1sap->oph.primitive, l1sap->oph.operation); diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 93b4de7..874ec15 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -954,63 +954,58 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1, GsmL1_PhDataInd_t *data_i } -static int handle_ph_ra_ind(struct femtol1_hdl *fl1, GsmL1_PhRaInd_t *ra_ind) +static int handle_ph_ra_ind(struct femtol1_hdl *fl1, GsmL1_PhRaInd_t *ra_ind, + struct msgb *l1p_msg) { struct gsm_bts_trx *trx = fl1->priv; struct gsm_bts *bts = trx->bts; struct gsm_bts_role_bts *btsb = bts->role; - struct osmo_phsap_prim pp; - struct lapdm_channel *lc; - uint8_t acc_delay; + struct osmo_phsap_prim *l1sap; + uint32_t fn; + uint8_t ra, acc_delay; + int rc; /* increment number of busy RACH slots, if required */ if (trx == bts->c0 && ra_ind->measParam.fRssi >= btsb->load.rach.busy_thresh) btsb->load.rach.busy++; - if (ra_ind->measParam.fLinkQuality < fl1->min_qual_rach) + if (ra_ind->measParam.fLinkQuality < fl1->min_qual_rach) { + msgb_free(l1p_msg); return 0; + } /* increment number of RACH slots with valid RACH burst */ if (trx == bts->c0) btsb->load.rach.access++; - DEBUGP(DL1C, "Rx PH-RA.ind"); dump_meas_res(LOGL_DEBUG, &ra_ind->measParam); - lc = get_lapdm_chan_by_hl2(fl1->priv, ra_ind->hLayer2); - if (!lc) { - LOGP(DL1C, LOGL_ERROR, "unable to resolve LAPD channel by hLayer2\n"); - return -ENODEV; + if (ra_ind->msgUnitParam.u8Size != 1) { + LOGP(DL1C, LOGL_ERROR, "PH-RACH-INDICATION has %d bits\n", + ra_ind->sapi); + msgb_free(l1p_msg); + return 0; } + fn = ra_ind->u32Fn; + ra = ra_ind->msgUnitParam.u8Buffer[0]; /* check for under/overflow / sign */ if (ra_ind->measParam.i16BurstTiming < 0) acc_delay = 0; else acc_delay = ra_ind->measParam.i16BurstTiming >> 2; - if (acc_delay > btsb->max_ta) { - LOGP(DL1C, LOGL_INFO, "ignoring RACH request %u > max_ta(%u)\n", - acc_delay, btsb->max_ta); - return 0; - } - - /* check for packet access */ - if (trx == bts->c0 - && (ra_ind->msgUnitParam.u8Buffer[0] & 0xf0) == 0x70) { - LOGP(DL1C, LOGL_INFO, "RACH for packet access\n"); - return pcu_tx_rach_ind(bts, ra_ind->measParam.i16BurstTiming, - ra_ind->msgUnitParam.u8Buffer[0], ra_ind->u32Fn); - } - - osmo_prim_init(&pp.oph, SAP_GSM_PH, PRIM_PH_RACH, - PRIM_OP_INDICATION, NULL); - - pp.u.rach_ind.ra = ra_ind->msgUnitParam.u8Buffer[0]; - pp.u.rach_ind.fn = ra_ind->u32Fn; - pp.u.rach_ind.acc_delay = acc_delay; - - return lapdm_phsap_up(&pp.oph, &lc->lapdm_dcch); + rc = msgb_trim(l1p_msg, sizeof(*l1sap)); + if (rc < 0) + MSGB_ABORT(l1p_msg, "No room for primitive data\n"); + l1sap = msgb_l1sap_prim(l1p_msg); + osmo_prim_init(&l1sap->oph, SAP_GSM_PH, PRIM_PH_RACH, PRIM_OP_INDICATION, + l1p_msg); + l1sap->u.rach_ind.ra = ra; + l1sap->u.rach_ind.acc_delay = acc_delay; + l1sap->u.rach_ind.fn = fn; + + return l1sap_up(trx, l1sap); } /* handle any random indication from the L1 */ @@ -1034,7 +1029,7 @@ static int l1if_handle_ind(struct femtol1_hdl *fl1, struct msgb *msg) rc = handle_ph_data_ind(fl1, &l1p->u.phDataInd, msg); break; case GsmL1_PrimId_PhRaInd: - rc = handle_ph_ra_ind(fl1, &l1p->u.phRaInd); + return handle_ph_ra_ind(fl1, &l1p->u.phRaInd, msg); break; default: break; -- 1.8.1.5 From holger at freyther.de Thu Sep 19 13:28:37 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 19 Sep 2013 15:28:37 +0200 Subject: [PATCH 04/20] Add RACH message to PH-/MPH-/TCH-SAP interface In-Reply-To: <1379592710-4811-4-git-send-email-jolly@eversberg.eu> References: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> <1379592710-4811-4-git-send-email-jolly@eversberg.eu> Message-ID: <20130919132837.GK6940@xiaoyu.lan> On Thu, Sep 19, 2013 at 02:11:49PM +0200, Andreas Eversberg wrote: > + lc = &trx->ts[0].lchan[4].lapdm_ch; > + if (!lc) { how can this ever be null? From andreas at eversberg.eu Thu Sep 19 14:04:21 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Thu, 19 Sep 2013 16:04:21 +0200 Subject: [PATCH 04/20] Add RACH message to PH-/MPH-/TCH-SAP interface In-Reply-To: <20130919132837.GK6940@xiaoyu.lan> References: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> <1379592710-4811-4-git-send-email-jolly@eversberg.eu> <20130919132837.GK6940@xiaoyu.lan> Message-ID: <523B0465.6030705@eversberg.eu> Holger Hans Peter Freyther wrote: > On Thu, Sep 19, 2013 at 02:11:49PM +0200, Andreas Eversberg wrote: > > >> + lc = &trx->ts[0].lchan[4].lapdm_ch; >> + if (!lc) { >> > how can this ever be null? > lc was a return vale from a function before, but you are right. this check is now obsolete, so i removed it. thanx! From jolly at eversberg.eu Thu Sep 19 12:11:50 2013 From: jolly at eversberg.eu (Andreas Eversberg) Date: Thu, 19 Sep 2013 14:11:50 +0200 Subject: [PATCH 05/20] Add PCH/AGCH message to PH-/MPH-/TCH-SAP interface In-Reply-To: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> References: <1379592710-4811-1-git-send-email-jolly@eversberg.eu> Message-ID: <1379592710-4811-5-git-send-email-jolly@eversberg.eu> This part moves PCH and AGCH message primitives from osmo-bts-sysmo to common part. --- src/common/l1sap.c | 17 +++++++++++++++++ src/osmo-bts-sysmo/l1_if.c | 28 ++++++++++++---------------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/common/l1sap.c b/src/common/l1sap.c index 996a589..16e1af8 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -108,6 +108,23 @@ static int l1sap_ph_rts_ind(struct gsm_bts_trx *trx, memcpy(p, si, GSM_MACBLOCK_LEN); else memcpy(p, fill_frame, GSM_MACBLOCK_LEN); + } else if (L1SAP_IS_CHAN_AGCH_PCH(chan_nr)) { + p = msgb_put(msg, GSM_MACBLOCK_LEN); + if (L1SAP_FN2CCCHBLOCK(fn) >= 1) { + /* PCH */ + struct gsm_bts_role_bts *btsb = trx->bts->role; + paging_gen_msg(btsb->paging_state, p, &g_time); + } else { + /* AGCH */ + /* special queue of messages from IMM ASS CMD */ + struct msgb *amsg = bts_agch_dequeue(trx->bts); + if (!amsg) + memcpy(p, fill_frame, GSM_MACBLOCK_LEN); + else { + memcpy(p, amsg->data, amsg->len); + msgb_free(amsg); + } + } } DEBUGP(DL1P, "Tx PH-DATA.req %02u/%02u/%02u chan_nr=%d link_id=%d\n", diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 874ec15..511b466 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -389,6 +389,14 @@ static int ph_data_req(struct gsm_bts_trx *trx, struct msgb *msg, subCh = 0x1f; if (L1SAP_IS_CHAN_BCCH(chan_nr)) { sapi = GsmL1_Sapi_Bcch; + } else if (L1SAP_IS_CHAN_AGCH_PCH(chan_nr)) { + /* The sapi depends on DSP configuration, not + * on the actual SYSTEM INFORMATION 3. */ + u8BlockNbr = L1SAP_FN2CCCHBLOCK(u32Fn); + if (u8BlockNbr >= 1) + sapi = GsmL1_Sapi_Pch; + else + sapi = GsmL1_Sapi_Agch; } else { LOGP(DL1C, LOGL_NOTICE, "unknown prim %d op %d " "chan_nr %d link_id %d\n", l1sap->oph.primitive, @@ -486,6 +494,10 @@ static uint8_t chan_nr_by_sapi(enum gsm_phys_chan_config pchan, case GsmL1_Sapi_Bcch: cbits = 0x10; break; + case GsmL1_Sapi_Agch: + case GsmL1_Sapi_Pch: + cbits = 0x12; + break; default: return 0; } @@ -499,7 +511,6 @@ static int handle_ph_readytosend_ind(struct femtol1_hdl *fl1, { struct gsm_bts_trx *trx = fl1->priv; struct gsm_bts *bts = trx->bts; - struct gsm_bts_role_bts *btsb = bts->role; struct msgb *resp_msg; GsmL1_PhDataReq_t *data_req; GsmL1_MsgUnitParam_t *msu_param; @@ -647,21 +658,6 @@ static int handle_ph_readytosend_ind(struct femtol1_hdl *fl1, msgb_free(pp.oph.msg); } break; - case GsmL1_Sapi_Agch: - /* special queue of messages from IMM ASS CMD */ - { - struct msgb *msg = bts_agch_dequeue(bts); - if (!msg) - memcpy(msu_param->u8Buffer, fill_frame, GSM_MACBLOCK_LEN); - else { - memcpy(msu_param->u8Buffer, msg->data, msg->len); - msgb_free(msg); - } - } - break; - case GsmL1_Sapi_Pch: - rc = paging_gen_msg(btsb->paging_state, msu_param->u8Buffer, &g_time); - break; case GsmL1_Sapi_TchF: case GsmL1_Sapi_TchH: /* only hit in case we have a RTP underflow, as real TCH -- 1.8.1.5 From andreas at eversberg.eu Thu Sep 19 13:26:41 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Thu, 19 Sep 2013 15:26:41 +0200 Subject: nanobts and sgsn Message-ID: <523AFB91.2090201@eversberg.eu> hi, after upgrading to latest openbsc/master, i experienced the following problem with sgsn: <0013> gprs_llc.c:506 LLC SAPI=1 C FCS=0x7b8d5fCMD=UI DATA <0013> gprs_llc.c:142 TLLI 0x990ea532 is foreign, converting to local TLLI 0xd90ea532 <0013> gprs_llc.c:789 LLC RX: unknown TLLI 0x990ea532, creating LLME on the fly <0013> gprs_llc.c:142 TLLI 0x990ea532 is foreign, converting to local TLLI 0xd90ea532 <0013> gprs_llc.c:372 LLC TX: unknown TLLI 0x990ea532, creating LLME on the fly <0012> gprs_bssgp.c:503 BSSGP BVCI=0 TLLI=990ea532 Rx LLC DISCARDED <0012> gprs_bssgp.c:376 BSSGP TLLI=0x990ea532 Rx UPLINK-UNITDATA <0013> gprs_llc.c:506 LLC SAPI=1 C FCS=0x30b960CMD=UI DATA <0013> gprs_llc.c:142 TLLI 0x990ea532 is foreign, converting to local TLLI 0xd90ea532 <0013> gprs_llc.c:789 LLC RX: unknown TLLI 0x990ea532, creating LLME on the fly <0013> gprs_llc.c:142 TLLI 0x990ea532 is foreign, converting to local TLLI 0xd90ea532 <0013> gprs_llc.c:372 LLC TX: unknown TLLI 0x990ea532, creating LLME on the fly <0012> gprs_bssgp.c:503 BSSGP BVCI=0 TLLI=990ea532 Rx LLC DISCARDED <0012> gprs_bssgp.c:376 BSSGP TLLI=0x990ea532 Rx UPLINK-UNITDATA <0013> gprs_llc.c:506 LLC SAPI=1 C FCS=0x280569CMD=UI DATA <0013> gprs_llc.c:142 TLLI 0x990ea532 is foreign, converting to local TLLI 0xd90ea532 <0013> gprs_llc.c:789 LLC RX: unknown TLLI 0x990ea532, creating LLME on the fly <0013> gprs_llc.c:142 TLLI 0x990ea532 is foreign, converting to local TLLI 0xd90ea532 <0013> gprs_llc.c:372 LLC TX: unknown TLLI 0x990ea532, creating LLME on the fly <0012> gprs_bssgp.c:503 BSSGP BVCI=0 TLLI=990ea532 Rx LLC DISCARDED the auth-policy is configured to "accept-all". any idea how to do deeper debugging? regards, andreass From dai.tran at khu.ac.kr Mon Sep 23 05:56:24 2013 From: dai.tran at khu.ac.kr (Dai H. Tran) Date: Mon, 23 Sep 2013 14:56:24 +0900 Subject: how gprs is called in openbsc, where to find the libgtb? Message-ID: Hello everyone, I just recently learn about openbsc, and still in the phase of compiling and try to run the osmo-nitb app. 1st problem The problem is one of my teammate said the osmo-nitb will also started/call the osmo-sgsn program, but after examine the code, I still don't know how the osmo-sgsn is called from osmp-nitb, may be I was wrong, anyone can help me with this, how can I activate osmo-sgsn from osmo-nitb, with extra arguments? 2nd problem Another question, when I try to compile osmo-sgsn, the gtp lib is missing, as define in the makefile: *if HAVE_LIBGTP* *bin_PROGRAMS = osmo-gbproxy osmo-sgsn* *else* *bin_PROGRAMS = osmo-gbproxy* *endif* I don't know where to get this lib, so I modified by adding osmo-sgsn to the *else clause* as-well to have osmo-sgsn compiled. I still can run osmo-sgsn, but it show error about the gtp socket, i think the configuration is not correct, but not because of missing gtp lib, should this be a problem? Best regards, Dai -------------- next part -------------- An HTML attachment was scrubbed... URL: From admin at manateeshome.com Mon Sep 23 06:52:31 2013 From: admin at manateeshome.com (Pierre Kim) Date: Mon, 23 Sep 2013 15:52:31 +0900 Subject: how gprs is called in openbsc, where to find the libgtb? In-Reply-To: References: Message-ID: <000301ceb829$7b124d50$7136e7f0$@manateeshome.com> Libgtp is included in the openggsn source tree. You'll have to install OpenGGSN first then recompile openbsc. Binaries will be generated automatically if libgtp is found. Osmo-sgsn, osmo-nitb and openggsn are separate binaries, you need to configure and start each of them separately. Regards, Pierre From: openbsc-bounces at lists.osmocom.org [mailto:openbsc-bounces at lists.osmocom.org] On Behalf Of Dai H. Tran Sent: Monday, September 23, 2013 2:56 PM To: openbsc at lists.osmocom.org Subject: how gprs is called in openbsc, where to find the libgtb? Hello everyone, I just recently learn about openbsc, and still in the phase of compiling and try to run the osmo-nitb app. 1st problem The problem is one of my teammate said the osmo-nitb will also started/call the osmo-sgsn program, but after examine the code, I still don't know how the osmo-sgsn is called from osmp-nitb, may be I was wrong, anyone can help me with this, how can I activate osmo-sgsn from osmo-nitb, with extra arguments? 2nd problem Another question, when I try to compile osmo-sgsn, the gtp lib is missing, as define in the makefile: if HAVE_LIBGTP bin_PROGRAMS = osmo-gbproxy osmo-sgsn else bin_PROGRAMS = osmo-gbproxy endif I don't know where to get this lib, so I modified by adding osmo-sgsn to the else clause as-well to have osmo-sgsn compiled. I still can run osmo-sgsn, but it show error about the gtp socket, i think the configuration is not correct, but not because of missing gtp lib, should this be a problem? Best regards, Dai -------------- next part -------------- An HTML attachment was scrubbed... URL: From ludovic at rateau.org Tue Sep 24 21:46:14 2013 From: ludovic at rateau.org (Ludovic Rateau) Date: Tue, 24 Sep 2013 23:46:14 +0200 Subject: Sms via SMPP - Questions Message-ID: Hi all, I'm working on OsmoNITB software and i am very interested in SMPP features. I have read some posts about SMPP in OSMONITB and i have some question about how to make it works. I have compiled openbsc ( based on http://openbsc.osmocom.org/trac/wiki/network_from_scratch ) with libsmpp34. All is good. When i start my OSMONITB, my netstat show listening port 2775. But how to connect and send a SMS via SMPP? I tried a little PHP script on github : https://github.com/onlinecity/php-smpp But i couldn't connect : INVALID SERVER ID Error 0xf Do i need to put a USERNAME and PASSWORD ? When i looked the code : in accept-all mode, all username and password are corrects. My BTS is in accept-all mode but i couldn't connect. So I tried an another program in C. And same error. Have you fixed this problem ? Is it working for you ? Second, Is there a mechanism to pass SMS from OSMONITB to an another server via SMPP ? Thanks for your help. -- *Ludovic RATEAU* R&D Engineer BJT PARTNERS -- -- *Ludovic RATEAU *Mobile : +33 6 04 10 5000 -------------- next part -------------- An HTML attachment was scrubbed... URL: From maicon.kist at inf.ufrgs.br Thu Sep 26 20:07:33 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Thu, 26 Sep 2013 17:07:33 -0300 Subject: Added patch to USSD iteration. Need help to continue. Message-ID: Hi list, I managed to add interaction to the USSD implemented in the OpenBSC. I attached a patch with the changes realized.The most important changes made are in the ussd.{c, h} files. I implemented the gsm0480_send_ussd_facility. Basically, I copied the gsm0480_send_response, change the GSM0480_OPERATION_CODE field value to GSM0480_OP_CODE_USS_REQUEST, removed the 2 bytes before this field and replaced the GSM0480_MTYPE_RELEASE_COMPLETE byte by GSM0480_MTYPE_FACILITY. Now, I don't know how to proceed. More precisely, I don't know what function is called in the OpenBSC when the user send the response in the mobile phone. Do you guys know the entry point function in this case ? Best Regards -------------- next part -------------- A non-text attachment was scrubbed... Name: patch_ussd.patch Type: application/octet-stream Size: 7245 bytes Desc: not available URL: -------------- next part -------------- From jolly at eversberg.eu Sun Sep 29 11:03:50 2013 From: jolly at eversberg.eu (Andreas Eversberg) Date: Sun, 29 Sep 2013 13:03:50 +0200 Subject: [PATCH] Menu App to select highram images from phone's flash memory Message-ID: <1380452630-1326-1-git-send-email-jolly@eversberg.eu> --- src/target/firmware/Makefile | 3 +- src/target/firmware/apps/menu/main.c | 353 ++++++++++++++++++++++++++++++++++ 2 files changed, 355 insertions(+), 1 deletions(-) create mode 100644 src/target/firmware/apps/menu/main.c diff --git a/src/target/firmware/Makefile b/src/target/firmware/Makefile index 42f7ad4..0f4120f 100644 --- a/src/target/firmware/Makefile +++ b/src/target/firmware/Makefile @@ -84,11 +84,12 @@ BOARD_se_j100_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS) # # List of all applications (meant to be overridden on command line) -APPLICATIONS?=hello_world compal_dsp_dump layer1 loader rssi +APPLICATIONS?=hello_world compal_dsp_dump layer1 loader rssi menu # Applications specific env requirements APP_loader_ENVIRONMENTS=compalram highram APP_rssi_ENVIRONMENTS=* -compalram +APP_menu_ENVIRONMENTS=* -highram # Various objects that are currently linked into all applications FLASH_OBJS=flash/cfi_flash.o diff --git a/src/target/firmware/apps/menu/main.c b/src/target/firmware/apps/menu/main.c new file mode 100644 index 0000000..47aadc4 --- /dev/null +++ b/src/target/firmware/apps/menu/main.c @@ -0,0 +1,353 @@ +/* Menu for Calypso Phone to load applicatios from flash */ + +/* (C) 2013 by Andreas Eversberg + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RAM 0x00820000 +#define MAGIC 0x0083ff00 + +enum key_codes key_code = KEY_INV; +static volatile enum key_states key_state; + +int cursor = 0, scroll_apps = 0; + +struct apps { + char name[16]; + void *start; + int len; +} apps[32]; + +int _memcmp(char *s1, char *s2, int size) +{ + int i; + + for (i = 0; i < size; i++) { + if (*s1 < *s2) + return -1; + if (*s1 > *s2) + return 1; + s1++; + s2++; + } + + return 0; +} + +static void locate_apps(void) +{ + int i, j, k; + char *p; + + memset(apps, 0, sizeof(apps)); + + for (j = 0, i = 0x010000; i < 0x200000; i += 0x10000) { + p = (char *)i; + /* check for highram header: "highram:" */ + if (!!_memcmp(p, "highram:", 8)) + continue; + p += 8; + /* check for app name after header: "highram:\n" */ + printf("found highram image at flash mem address 0x%p\n", + (char *)i); + for (k = 0; k < (int)sizeof(apps[j].name) - 1; k++) { + if (p[k] == '\n') + break; + } + if (k == sizeof(apps[j].name) - 3) { + printf("skipping: corrupt highram header, no '\\n' " + "after image name or name more larger than %d " + "digits\n", (int)sizeof(apps[j].name) - 3); + continue; + } + if (j < 9) + apps[j].name[0] = '1' + j; + else if (j == 9) + apps[j].name[0] = '0'; + else + apps[j].name[0] = ' '; + apps[j].name[1] = ' '; + memcpy(apps[j].name + 2, p, k); + apps[j].len = 0x20000; + p += k + 1; + /* p points to highram image after header */ + apps[j].start = p; + j++; + } +} + +static void wait_key_release(void) +{ + /* wait for key release */ + while (key_state == PRESSED) { + delay_ms(10); + keypad_poll(); + } +} + +static void load_app(void) +{ + static int i; + static void (*f) (void) = (void (*)(void))RAM; + + wait_key_release(); + + local_irq_disable(); + + for (i = 0; i < apps[cursor].len; i++) + ((unsigned char *)RAM)[i] = ((unsigned char *)apps[cursor].start)[i]; + f(); +} + +/* UI */ + +static void refresh_display(void) +{ +#if 0 + char text[16]; + int bat = battery_info.battery_percent; +#endif + int i; + + fb_clear(); + + /* header */ + fb_setbg(FB_COLOR_WHITE); + if (1) { + fb_setfg(FB_COLOR_BLUE); + fb_setfont(FB_FONT_HELVR08); + fb_gotoxy(0, 7); + fb_putstr("Osmocom Menu", -1); + fb_setfg(FB_COLOR_RGB(0xc0, 0xc0, 0x00)); + fb_setfont(FB_FONT_SYMBOLS); +#if 0 + fb_gotoxy(framebuffer->width - 15, 8); + if (bat >= 100 && (battery_info.flags & BATTERY_CHG_ENABLED) + && !(battery_info.flags & BATTERY_CHARGING)) + fb_putstr("@HHBC", framebuffer->width); + else { + sprintf(text, "@%c%c%cC", (bat >= 30) ? 'B':'A', + (bat >= 60) ? 'B':'A', (bat >= 90) ? 'B':'A'); + fb_putstr(text, framebuffer->width); + } +#endif + fb_gotoxy(0, 8); + fb_putstr("GGEGG", framebuffer->width); + fb_setfg(FB_COLOR_GREEN); + fb_gotoxy(0, 10); + fb_boxto(framebuffer->width - 1, 10); + } + fb_setfg(FB_COLOR_BLACK); + fb_setfont(FB_FONT_C64); + + + for (i = 0; i < 5; i++) { + if (!apps[scroll_apps + i].name) + break; + if (scroll_apps + i == cursor) { + fb_setfg(FB_COLOR_WHITE); + fb_setbg(FB_COLOR_BLUE); + } + fb_gotoxy(0, 20 + i * 10); + fb_putstr(apps[scroll_apps + i].name, + framebuffer->width); + if (scroll_apps + i == cursor) { + fb_setfg(FB_COLOR_BLACK); + fb_setbg(FB_COLOR_WHITE); + } + } + if (i == 0) { + fb_gotoxy(0, 50); + fb_putstr("No apps!", -1); + } + + fb_flush(); +} + +static void handle_key_code() +{ + if (key_code == KEY_INV) + return; + + switch (key_code) { + case KEY_1: + case KEY_2: + case KEY_3: + case KEY_4: + case KEY_5: + case KEY_6: + case KEY_7: + case KEY_8: + case KEY_9: + if (apps[key_code - KEY_1].len) { + cursor = key_code - KEY_1; + load_app(); + } + break; + case KEY_0: + if (apps[9].len) { + cursor = 9; + load_app(); + } + break; + case KEY_UP: + if (cursor == 0) + return; + cursor--; + if (cursor < scroll_apps) + scroll_apps = cursor; + refresh_display(); + break; + case KEY_DOWN: + if (!apps[cursor + 1].name[0]) + return; + cursor++; + if (cursor >= scroll_apps + 5) + scroll_apps = cursor - 4; + refresh_display(); + break; + case KEY_OK: + if (apps[cursor].len) + load_app(); + break; + case KEY_POWER: + wait_key_release(); + twl3025_power_off(); + break; + default: + break; + } + + key_code = KEY_INV; +} + +/* Main Program */ +const char *hr = "======================================================================\n"; + +static void key_handler(enum key_codes code, enum key_states state) +{ + key_state = state; + + if (state != PRESSED) + return; + + key_code = code; +} + +extern void putchar_asm(uint32_t c); + +static const uint8_t phone_ack[] = { 0x1b, 0xf6, 0x02, 0x00, 0x41, 0x03, 0x42 }; + +int main(void) +{ + int i; + + /* Simulate a compal loader saying "ACK" */ + for (i = 0; i < (int)sizeof(phone_ack); i++) { + putchar_asm(phone_ack[i]); + } + + board_init(0); + + puts("\n\nOsmocomBB Menu (revision " GIT_REVISION ")\n"); + puts(hr); + + fb_clear(); + + fb_setfg(FB_COLOR_BLACK); + fb_setbg(FB_COLOR_WHITE); + fb_setfont(FB_FONT_HELVB14); + + fb_gotoxy(2,20); + fb_putstr("menu",framebuffer->width-4); + + fb_setfg(FB_COLOR_RED); + fb_setbg(FB_COLOR_BLUE); + + fb_gotoxy(2,25); + fb_boxto(framebuffer->width-3,38); + + fb_setfg(FB_COLOR_WHITE); + fb_setfont(FB_FONT_HELVR08); + fb_gotoxy(8,33); + fb_putstr("osmocom-bb",framebuffer->width-4); + + fb_flush(); + + /* Dump device identification */ + dump_dev_id(); + puts(hr); + + /* Dump clock config before PLL set */ + calypso_clk_dump(); + puts(hr); + + keypad_set_handler(&key_handler); + + /* Dump clock config after PLL set */ + calypso_clk_dump(); + puts(hr); + +// display_unset_attr(DISP_ATTR_INVERT); + + locate_apps(); + + while (1) { + for (i = 0; i < 50; i++) { + keypad_poll(); + delay_ms(10); + osmo_timers_update(); + handle_key_code(); + } + refresh_display(); + } + + /* NOT REACHED */ + + twl3025_power_off(); +} + -- 1.7.3.4 From andreas at eversberg.eu Sun Sep 29 11:55:24 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Sun, 29 Sep 2013 13:55:24 +0200 Subject: [PATCH] Menu App to select highram images from phone's flash memory In-Reply-To: <1380452630-1326-1-git-send-email-jolly@eversberg.eu> References: <1380452630-1326-1-git-send-email-jolly@eversberg.eu> Message-ID: <5248152C.9050107@eversberg.eu> hi, this forthcoming tutorial describes the usage (flashing) of the menu app: https://bb.osmocom.org/trac/wiki/flashing_new andreas