From patrick.voerman at gmail.com Mon Aug 5 14:11:39 2013 From: patrick.voerman at gmail.com (Patrick Voerman) Date: Mon, 5 Aug 2013 14:11:39 +0000 (UTC) Subject: Buying a nanoBTS References: Message-ID: Patrick Klapper googlemail.com> writes: > > Hello, > > I am interested in buying a nanoBTS. > The sales department of ip.access told me, that they only sell their products to mobile operators. > > Where can I buy an ip.access nanoBTS (GSM1800) and what's its price? > > Regards > > Patrick > > Hello Patrick, Still searching for the nanoBTS? I have one for sale. Kind regards, Patrick ======= From zero-kelvin at gmx.de Thu Aug 22 20:07:27 2013 From: zero-kelvin at gmx.de (dexter) Date: Thu, 22 Aug 2013 22:07:27 +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: <52166F7F.3080006@gmx.de> Hi All. It's time Again! This is the announcement for the next Osmocom Berlin meeting. Aug 28, 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 laforge at gnumonks.org Sat Aug 24 13:41:55 2013 From: laforge at gnumonks.org (Harald Welte) Date: Sat, 24 Aug 2013 15:41:55 +0200 Subject: UPDATE -- Osmocom Berlin User Group meeting -- NEXT MEETING In-Reply-To: <52166F7F.3080006@gmx.de> References: <502d01a9.mirider@mirider.augusta.de> <20120818115942.GV29525@prithivi.gnumonks.org> <51AF0097.10402@gmx.de> <20130605121428.GA10030@nataraja.gnumonks.org> <52166F7F.3080006@gmx.de> Message-ID: <20130824134155.GD16941@nataraja.gnumonks.org> Hi Dexter, thanks again for continuing the tradition of the meeting. After a long period of absence, I am planning on attending again on August 28. Looking forward to it! Regards, Harald On Thu, Aug 22, 2013 at 10:07:27PM +0200, dexter wrote: > Hi All. > > It's time Again! > > This is the announcement for the next Osmocom Berlin meeting. > > Aug 28, 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 > -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From choukoumoun at gmail.com Sat Aug 31 21:11:49 2013 From: choukoumoun at gmail.com (choukoumoun) Date: Sat, 31 Aug 2013 23:11:49 +0200 Subject: Bs11 problem on startup. In-Reply-To: <522259D3.6050201@gmail.com> References: <522259D3.6050201@gmail.com> Message-ID: <52225C15.7030407@gmail.com> Hello, Where can download/find the *.SWL file for flash the BS11 ? Thanks bye On 12/06/2013 00:48, choukoumoun wrote: > Hello, > > Thanks you very much for your help (Love the open-source/hacker community) > I'll try that tomorrow and soon I will return. > > Bye! > > Le 12/06/2013 00:06, Sergey V. Efimov a ?crit : >> Hello, >> >> Yep, it seems you need to reflash your BS11. You can start with >> "bs11_config -S" to download the safety file into the station if you >> have one. >> The next step is to download the real working firmware into the >> station. It can take up to 1,5 hours depending on the various conditions. >> You need to get several files, listed at >> http://openbsc.osmocom.org/trac/wiki/bs11_config, try to ask your seller. >> >> At the end of the flashing process (after reboot) you should see >> MBCCU0/MBCCU1 No Load / Load messages. >> >> Sergey. >> >> On Jun 12, 2013, at 1:48 AM, choukoumoun wrote: >> >>> Hello, >>> >>> it is the boot-up log for my Bs11 >>> >>> >>> >>> LMT LOGON: ACK >>> >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 load SMU Intended Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> PHASE: 1 Unknow Abis-link: down >>> >>> >>> Iawait yourreplywith great pleasure >>> >>> best, >>> Choukoumoun >>> >>> Le 10/06/2013 11:58, Sergey V. Efimov a ?crit : >>>> Hello, >>>> >>>> I recall that something similar happened when I tried to monitor freshly received >>>> BS-11 without operating firmware. Could you please provide full boot-up log. >>>> >>>> Sergey. >>>> >>>> On Jun 10, 2013, at 1:36 AM, choukoumoun wrote: >>>> >>>>> Hello list, >>>>> >>>>> I have a problem with BS11 at startup: >>>>> >>>>> >>>>> When I put the BS11 voltage and that I connect in serial and I run: >>>>> >>>>> ./bs11_config-p / dev/ttyUSB0 query >>>>> >>>>> I like the result: >>>>> >>>>> >>>>> PHASE 1: unknown Abis-link: Down >>>>> >>>>> PHASE 1: unknown Abis-link: Down >>>>> >>>>> PHASE 1: unknown Abis-link: Down >>>>> >>>>> PHASE 1: unknown Abis-link: Down >>>>> >>>>> PHASE 1: unknown Abis-link: Down >>>>> >>>>> PHASE 1: unknown Abis-link: Down >>>>> >>>>> PHASE 1: unknown Abis-link: Down >>>>> >>>>> >>>>> constantly and eternally ...... >>>>> >>>>> Any idea?? >>>>> >>>>> >>>>> thank you >>>>> >>>>> >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Thu Aug 1 12:48:42 2013 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 1 Aug 2013 20:48:42 +0800 Subject: SGSN Crash Report In-Reply-To: <20130731201649.GA1625@xiaoyu.lan> References: <000601ce6edc$31323ec0$9396bc40$@net> <20130622075032.GB31037@nataraja.gnumonks.org> <001201ce6fc0$2c92df70$85b89e50$@net> <20130624054416.GB21497@xiaoyu.lan> <000301ce77b9$cb9444f0$62bcced0$@net> <20130731201649.GA1625@xiaoyu.lan> Message-ID: <20130801124842.GD8465@nataraja.gnumonks.org> Hi Holger, On Wed, Jul 31, 2013 at 10:16:49PM +0200, Holger Hans Peter Freyther wrote: > Maybe you want to try to fix the issue based on this setup? I _think_ the following (untested) patch should do the trick. From laforge at gnumonks.org Thu Aug 1 12:45:46 2013 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 1 Aug 2013 20:45:46 +0800 Subject: [PATCH] SNDCP: don't msgb_free() if gprs_llc_tx_ui() fails. Message-ID: the gprs_llc_tx_ui() will call down to BSSGP/NS, which in turn will call msgb_free() themselves in their error path, so the msgb is already freed at that time. As discussed on the mailing list quite some time ago, msgb ownership policy/rules and implementation need to be more clearly defined, and this definition adopted in the implementation. Thanks to Holger for reproducing this. --- openbsc/src/gprs/gprs_sndcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openbsc/src/gprs/gprs_sndcp.c b/openbsc/src/gprs/gprs_sndcp.c index 853f8db..6564ffb 100644 --- a/openbsc/src/gprs/gprs_sndcp.c +++ b/openbsc/src/gprs/gprs_sndcp.c @@ -420,7 +420,8 @@ static int sndcp_send_ud_frag(struct sndcp_frag_state *fs) rc = gprs_llc_tx_ui(fmsg, lle->sapi, 0, fs->mmcontext); if (rc < 0) { /* abort in case of error, do not advance frag_nr / next_byte */ - msgb_free(fmsg); + /* do not msgb_free() here, as the lower layer is doing + * that if an actual transmission error occurs */ return rc; } -- 1.8.3.2 -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Thu Aug 1 15:06:37 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 1 Aug 2013 17:06:37 +0200 Subject: SGSN Crash Report In-Reply-To: <20130801124842.GD8465@nataraja.gnumonks.org> References: <000601ce6edc$31323ec0$9396bc40$@net> <20130622075032.GB31037@nataraja.gnumonks.org> <001201ce6fc0$2c92df70$85b89e50$@net> <20130624054416.GB21497@xiaoyu.lan> <000301ce77b9$cb9444f0$62bcced0$@net> <20130731201649.GA1625@xiaoyu.lan> <20130801124842.GD8465@nataraja.gnumonks.org> Message-ID: <20130801150637.GA6674@xiaoyu.lan> On Thu, Aug 01, 2013 at 08:48:42PM +0800, Harald Welte wrote: > > I _think_ the following (untested) patch should do the trick. nope, the whole ownership model is wrong. BSSGP will not delete in most casess, NS will delete them. a.) we use the trick i mentioned (e.g. talloc_steal) b.) we review the entire stack and fix and enforce the ownershop From holger at freyther.de Thu Aug 1 17:34:52 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 1 Aug 2013 19:34:52 +0200 Subject: SGSN Crash Report In-Reply-To: <20130801150637.GA6674@xiaoyu.lan> References: <000601ce6edc$31323ec0$9396bc40$@net> <20130622075032.GB31037@nataraja.gnumonks.org> <001201ce6fc0$2c92df70$85b89e50$@net> <20130624054416.GB21497@xiaoyu.lan> <000301ce77b9$cb9444f0$62bcced0$@net> <20130731201649.GA1625@xiaoyu.lan> <20130801124842.GD8465@nataraja.gnumonks.org> <20130801150637.GA6674@xiaoyu.lan> Message-ID: <20130801173452.GF3997@xiaoyu.lan> On Thu, Aug 01, 2013 at 05:06:37PM +0200, Holger Hans Peter Freyther wrote: > On Thu, Aug 01, 2013 at 08:48:42PM +0800, Harald Welte wrote: > > > > I _think_ the following (untested) patch should do the trick. > > nope, the whole ownership model is wrong. BSSGP will not delete > in most casess, NS will delete them. > > > a.) we use the trick i mentioned (e.g. talloc_steal) > b.) we review the entire stack and fix and enforce the ownershop > E.g. I started to do b.) in OpenBSC and libosmocore.. but it requires quite some work.. to descend all the way down to sendmsg/write and then all the way up to all callers... in my changes I am still on BSSGP and have not decended down... to NS.. specially in the FlowControl code it is not too clear what will out_cb handlers. :) openbsc: diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c index e2d3160..6f209d4 100644 --- a/openbsc/src/gprs/gprs_llc.c +++ b/openbsc/src/gprs/gprs_llc.c @@ -422,6 +422,7 @@ int gprs_llc_tx_ui(struct msgb *msg, uint8_t sapi, int command, if (msg->len > lle->params.n201_u) { LOGP(DLLC, LOGL_ERROR, "Cannot Tx %u bytes (N201-U=%u)\n", msg->len, lle->params.n201_u); + msgb_free(msg); return -EFBIG; } @@ -479,6 +480,7 @@ int gprs_llc_tx_ui(struct msgb *msg, uint8_t sapi, int command, kc, iv, GPRS_CIPH_SGSN2MS); if (rc < 0) { LOGP(DLLC, LOGL_ERROR, "Error crypting UI frame: %d\n", rc); + msgb_free(msg); return rc; } diff --git a/openbsc/src/gprs/gprs_sndcp.c b/openbsc/src/gprs/gprs_sndcp.c index 853f8db..ffbfab5 100644 --- a/openbsc/src/gprs/gprs_sndcp.c +++ b/openbsc/src/gprs/gprs_sndcp.c @@ -420,7 +420,6 @@ static int sndcp_send_ud_frag(struct sndcp_frag_state *fs) rc = gprs_llc_tx_ui(fmsg, lle->sapi, 0, fs->mmcontext); if (rc < 0) { /* abort in case of error, do not advance frag_nr / next_byte */ - msgb_free(fmsg); return rc; } libosmocore: diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index 5ef1887..325e35c 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -609,17 +609,21 @@ static int fc_queue_timer_cfg(struct bssgp_flow_control *fc) } /* Enqueue a PDU in the flow control queue for delayed transmission */ -static int fc_enqueue(struct bssgp_flow_control *fc, struct msgb *msg, +static int fc_enqueue(struct bssgp_flow_control *fc, struct msgb OWNS(*msg), uint32_t llc_pdu_len, void *priv) { struct bssgp_fc_queue_element *fcqe; - if (fc->queue_depth >= fc->max_queue_depth) + if (fc->queue_depth >= fc->max_queue_depth) { + msgb_free(msg); return -ENOSPC; + } fcqe = talloc_zero(fc, struct bssgp_fc_queue_element); - if (!fcqe) + if (!fcqe) { + msgb_free(msg); return -ENOMEM; + } fcqe->msg = msg; fcqe->llc_pdu_len = llc_pdu_len; fcqe->priv = priv; @@ -687,7 +691,7 @@ static int _bssgp_tx_dl_ud(struct bssgp_flow_control *fc, struct msgb *msg, /* input function of the flow control implementation, called first * for the MM flow control, and then as the MM flow control output * callback in order to perform BVC flow control */ -int bssgp_fc_in(struct bssgp_flow_control *fc, struct msgb *msg, +int bssgp_fc_in(struct bssgp_flow_control *fc, struct msgb OWNS(*msg), uint32_t llc_pdu_len, void *priv) { struct timeval time_now; @@ -696,6 +700,7 @@ int bssgp_fc_in(struct bssgp_flow_control *fc, struct msgb *msg, LOGP(DBSSGP, LOGL_NOTICE, "Single PDU (size=%u) is larger " "than maximum bucket size (%u)!\n", llc_pdu_len, fc->bucket_size_max); + msgb_free(msg) return -EIO; } @@ -1018,7 +1023,7 @@ int bssgp_rcvmsg(struct msgb *msg) return rc; } -int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime, +int bssgp_tx_dl_ud(struct msgb OWNS(*msg), uint16_t pdu_lifetime, struct bssgp_dl_ud_par *dup) { struct bssgp_bvc_ctx *bctx; @@ -1035,6 +1040,7 @@ int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime, if (bvci <= BVCI_PTM ) { LOGP(DBSSGP, LOGL_ERROR, "Cannot send DL-UD to BVCI %u\n", bvci); + msgb_free(msg); return -EINVAL; } @@ -1042,6 +1048,7 @@ int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime, if (!bctx) { LOGP(DBSSGP, LOGL_ERROR, "Cannot send DL-UD to unknown BVCI %u\n", bvci); + msgb_free(msg) return -ENODEV; } From dchardware at gmail.com Thu Aug 1 23:41:14 2013 From: dchardware at gmail.com (Sipos Csaba) Date: Fri, 2 Aug 2013 01:41:14 +0200 Subject: Osmo-nitb v_0.13.0.48-9e22 broke compatibility with Nokia InSite In-Reply-To: <20130729210417.GC7983@xiaoyu.lan> References: <417565018.20130629155826@freemail.hu> <20130629142041.GC3330@xiaoyu.lan> <1355509309.20130629235206@freemail.hu> <20130630060408.GH23402@xiaoyu.lan> <12210700172.20130630120006@freemail.hu> <20130630112152.GK23402@xiaoyu.lan> <351331868.20130728173457@freemail.hu> <20130728163209.GC3624@xiaoyu.lan> <1968404558.20130728233905@freemail.hu> <20130729210417.GC7983@xiaoyu.lan> Message-ID: <347178375.20130802014114@freemail.hu> Hey Holger, After placing some markers into the code, I have found the part which is responsible for proper close of the OML connection: lapd_sap_stop(ts->lapd, link->tei, link->sapi); which is called properly by the Nokia related code, after the ACK got received for the RESET_REQ. The lapd connection closes as it should: Fri Aug 2 01:10:16 2013 <0018> input/lapd.c:513 LAPD DL-RELEASE request TEI=1 SAPI=62 Fri Aug 2 01:10:16 2013 <0018> lapd_core.c:2183 Message DL-RELEASE-REQUEST received in state LAPD_STATE_MF_EST Fri Aug 2 01:10:16 2013 <0018> lapd_core.c:2024 perform local release Fri Aug 2 01:10:16 2013 <0018> lapd_core.c:229 new state LAPD_STATE_MF_EST -> LAPD_STATE_IDLE Fri Aug 2 01:10:16 2013 <0018> lapd_core.c:222 stop T203 Fri Aug 2 01:10:16 2013 <0018> input/lapd.c:628 LAPD DL-RELEASE confirm TEI=1 SAPI=62 Now OML lapd connection is closed, but for some unkown reason lapd_core.c still try to process the received lapd messages for an already closed connection, which causes the segfault: Fri Aug 2 01:10:16 2013 <0018> lapd_core.c:1781 lapd_send_i() called from line 1615 Segmentation fault (core dumped) And this is not because the Nokia related code tries to send something when the lapd connection is closed. From the above log, it is clear that the LAPD connection got terminated as it should, so it seems this is a problem with lapd_core.c in general, that for an already closed connection, if something got received on the OML timeslot, lapd_core.c tries to process it. And this behavior leads to the segfault. This is normal, that lapd_core.c tries to process data related to an already closed connection? BR, Csaba From peter at stuge.se Fri Aug 2 01:10:52 2013 From: peter at stuge.se (Peter Stuge) Date: Fri, 2 Aug 2013 03:10:52 +0200 Subject: Osmo-nitb v_0.13.0.48-9e22 broke compatibility with Nokia InSite In-Reply-To: <347178375.20130802014114@freemail.hu> References: <20130629142041.GC3330@xiaoyu.lan> <1355509309.20130629235206@freemail.hu> <20130630060408.GH23402@xiaoyu.lan> <12210700172.20130630120006@freemail.hu> <20130630112152.GK23402@xiaoyu.lan> <351331868.20130728173457@freemail.hu> <20130728163209.GC3624@xiaoyu.lan> <1968404558.20130728233905@freemail.hu> <20130729210417.GC7983@xiaoyu.lan> <347178375.20130802014114@freemail.hu> Message-ID: <20130802011052.19826.qmail@stuge.se> Sipos Csaba wrote: > Fri Aug 2 01:10:16 2013 <0018> input/lapd.c:628 LAPD DL-RELEASE confirm TEI=1 SAPI=62 Ok. Do you have a later message from the following line? LOGP(DLLAPD, LOGL_INFO, "I received in state %s\n", lapd_state_names[dl->state]); > This is normal, that lapd_core.c tries to process data related to > an already closed connection? If it is the root cause of an error then of course it isn't correct. "Normal" isn't a very good word when describing software algorithms. //Peter From alexander.chemeris at gmail.com Thu Aug 1 21:03:47 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Fri, 2 Aug 2013 01:03:47 +0400 Subject: Adding SDR Drivers In-Reply-To: References: Message-ID: Ash, OsmoBTS does support SDR devices, just use osmo-trx (improved transceiver from OpenBTS) and follow this guide: http://openbsc.osmocom.org/trac/wiki/network_from_scratch With it you could get any Ettus device (with varying success) or UmTRX working with OsmoBTS. You're welcome to contribute patches to add BladeRF support, though it needs timed samples support first. I'm CC'ing Thomas Tsou who is maintaining the transceiver. On Thu, Aug 1, 2013 at 2:26 AM, Ash Gibbons wrote: > Hello, > > I am wonder how to add support for other Transceivers, in particular the > BladeRF ( http://nuand.com/ ). If anyone has a start point for me to learn > how to do this, it would be fantastic! > > Many thanks -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From dmi3sol at gmail.com Thu Aug 1 03:32:02 2013 From: dmi3sol at gmail.com (Dmitri Soloviev) Date: Thu, 1 Aug 2013 07:32:02 +0400 Subject: help needed to configure osmo-bsc (MGCP) Message-ID: hi Harald, I'm running OpenBSC in BSC-only mode, where my A-interface gateway substitutes an MSC (soft switch) to BSC. On the other side, A-interface gateway has a legacy BSSAP/e1 connectivity. OpenBSC configuration file is derived from doc/examples/osmo-bsc/osmo-bsc.cfg everything is fine with control over sccp/ip, but MGCP gateway port (2427) is not binded to a public ip. so, my questions are - in which way media control is assumed to be performed? - how this control is reflected in osmo-bsc.cfg in fact, I'm expecting osmo-BSC to run exactly as the BSC from ip.access, that establishes SCCP/ip link and accepts MGCP commands from a soft switch Thank you, Dmitri -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Thu Aug 1 04:46:17 2013 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 01 Aug 2013 12:46:17 +0800 Subject: help needed to configure osmo-bsc (MGCP) In-Reply-To: References: Message-ID: <194777e5-1dc6-401f-985f-1d31b78ba886@email.android.com> Did you run the bsc-mgcp process in addition to the osmo-bsc process? It should bind to MGCP. Regards, harald Dmitri Soloviev wrote: >hi Harald, > >I'm running OpenBSC in BSC-only mode, where my A-interface gateway >substitutes an MSC (soft switch) to BSC. On the other side, A-interface >gateway has a legacy BSSAP/e1 connectivity. >OpenBSC configuration file is derived from >doc/examples/osmo-bsc/osmo-bsc.cfg > >everything is fine with control over sccp/ip, but MGCP gateway port >(2427) >is not binded to a public ip. > >so, my questions are >- in which way media control is assumed to be performed? >- how this control is reflected in osmo-bsc.cfg > >in fact, I'm expecting osmo-BSC to run exactly as the BSC from >ip.access, >that establishes SCCP/ip link and accepts MGCP commands from a soft >switch > >Thank you, >Dmitri -- Sent from my mobile phone. Please excuse my brevity. From bnt2025 at googlemail.com Fri Aug 2 12:39:13 2013 From: bnt2025 at googlemail.com (Ash Gibbons) Date: Fri, 2 Aug 2013 13:39:13 +0100 Subject: IMEI in HLR Message-ID: Is there a way to add subscribers by just using their IMEI, this is a lot easier to obtain the the IMSI. I can see there is and Equipment and EquipmentWatch table in hlr.sqlite in the Osmo-NITB folder, but there is no Authorised field like in the Subscribers table. Many thanks, -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.chemeris at gmail.com Fri Aug 2 12:54:45 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Fri, 2 Aug 2013 16:54:45 +0400 Subject: IMEI in HLR In-Reply-To: References: Message-ID: No, you could add subscribers only by IMSI, as it's how they are addressed in the network. You could also allow open registration to register mobiles and then turn it back to closed registration. Or you could implement this feature - sources are here :) On Fri, Aug 2, 2013 at 4:39 PM, Ash Gibbons wrote: > Is there a way to add subscribers by just using their IMEI, this is a lot > easier to obtain the the IMSI. > > I can see there is and Equipment and EquipmentWatch table in hlr.sqlite in > the Osmo-NITB folder, but there is no Authorised field like in the > Subscribers table. > > Many thanks, -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From bnt2025 at googlemail.com Fri Aug 2 13:55:31 2013 From: bnt2025 at googlemail.com (Ash Gibbons) Date: Fri, 2 Aug 2013 14:55:31 +0100 Subject: IMEI in HLR Message-ID: T hats a shame. Reading http://openbsc.osmocom.org/trac/wiki/osmo-nitb it states; " We obtain the IMSI and IMEI of every LOCATION UPDATING REQUEST, and then if neccessary create a new entry for the equipment as well as the subscribers in the respective tables. " Is there a specific table that all rejected handsets go into or a mixture of Equipment, EquipmentWatch, Meta and Subcriber? Many thanks, -------------- next part -------------- An HTML attachment was scrubbed... URL: From bnt2025 at googlemail.com Fri Aug 2 14:07:25 2013 From: bnt2025 at googlemail.com (Ash Gibbons) Date: Fri, 2 Aug 2013 15:07:25 +0100 Subject: IMEI in HLR Message-ID: Not really, if I have a temporary subscriber coming onto the network, I would like to be able just to use their IMEI instead of going through the trouble of getting their IMSI. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchardware at gmail.com Fri Aug 2 15:05:43 2013 From: dchardware at gmail.com (Sipos Csaba) Date: Fri, 2 Aug 2013 17:05:43 +0200 Subject: Osmo-nitb v_0.13.0.48-9e22 broke compatibility with Nokia In-Reply-To: References: Message-ID: <1065613922.20130802170543@freemail.hu> Hi Peter, > Ok. Do you have a later message from the following line? > LOGP(DLLAPD, LOGL_INFO, "I received in state %s\n", lapd_state_names[dl->state]); Sure, this is how it looks with all relevant debugging enabled: Fri Aug 2 16:50:13 2013 <0018> lapd_core.c:1465 I received in state LAPD_STATE_MF_EST Fri Aug 2 16:50:13 2013 <0018> lapd_core.c:1548 incrementing V(R) to 1 Fri Aug 2 16:50:13 2013 <0018> lapd_core.c:222 stop T203 Fri Aug 2 16:50:13 2013 <0018> lapd_core.c:206 start T203 Fri Aug 2 16:50:13 2013 <0018> lapd_core.c:1557 message in single I frame Fri Aug 2 16:50:13 2013 <001b> e1_input.c:594 RX: 80 80 00 08 81 00 00 01 5f 23 01 01 sapi=62 tei=1 Fri Aug 2 16:50:13 2013 <0005> bts_nokia_site.c:1668 Nokia: Abis received! Fri Aug 2 16:50:13 2013 <0005> bts_nokia_site.c:1688 ABIS_OM_MDISC_FOM Fri Aug 2 16:50:13 2013 <0005> bts_nokia_site.c:1515 (0x81) NOKIA_BTS_ACK Fri Aug 2 16:50:13 2013 <0005> bts_nokia_site.c:1547 ACK = 1 Fri Aug 2 16:50:13 2013 <0005> bts_nokia_site.c:1588 Nokia: STOP OML & RSL lapd (cause: RESET) Fri Aug 2 16:50:13 2013 <0018> input/lapd.c:513 LAPD DL-RELEASE request TEI=1 SAPI=62 Fri Aug 2 16:50:13 2013 <0018> lapd_core.c:2183 Message DL-RELEASE-REQUEST received in state LAPD_STATE_MF_EST Fri Aug 2 16:50:13 2013 <0018> lapd_core.c:2024 perform local release Fri Aug 2 16:50:13 2013 <0018> lapd_core.c:229 new state LAPD_STATE_MF_EST -> LAPD_STATE_IDLE Fri Aug 2 16:50:13 2013 <0018> lapd_core.c:222 stop T203 Fri Aug 2 16:50:13 2013 <0018> input/lapd.c:628 LAPD DL-RELEASE confirm TEI=1 SAPI=62 Fri Aug 2 16:50:13 2013 <001b> e1_input.c:585 DL_REL: sapi(62) tei(1) Fri Aug 2 16:50:13 2013 <001b> bsc_init.c:318 Lost some E1 TEI link: 1 0x887f038 Fri Aug 2 16:50:13 2013 <0018> lapd_core.c:1781 lapd_send_i() called from line 1615 Segmentation fault (core dumped) bsc_init.c probably complaining because the LAPD connection is closed, but the OML context does not. Maybe this is the root cause of the problem: if the OML context not disconnected with the LAPD connection, it still listens on the OML timeslot and if something got received, it tries to process it. But still: this is not how it should work. The OML context is not closed, because we are waiting for the already resetting BTS, then the OML lapd got restarted again (after the RESET_TIMER expired). My opinion is that after we closed the lapd connection, it should not reactivate itself, if data appears on the OML TS. BR, Csaba From ml at bongiorni.eu Sun Aug 4 10:28:14 2013 From: ml at bongiorni.eu (Luca Bongiorni) Date: Sun, 4 Aug 2013 13:28:14 +0300 Subject: Picocell EDGE Omnicell@Work - Nokia/RadioFrame Networks, Inc. Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey folks, I have just received this new piece of hardware and I wanted to share some preliminary info about it. As far as I noticed, the picocell was used by Orange UK some years ago. As you will see from the photos below the board has different populated pins, which one of them seems a 14-pin JTAG connector. (I apologise for the low quality of the images, but at the moment is the best I can do) At the moment I am unable to fully test it cause logic analyzer, jtag and uart connectors are physically not with me. In the meanwhile I will get them, I was wondering if someone of you guys already had the opportunity to play with it. Or have more info/specs/etc. about it. - ------------------------------------- IC PRIXPH425BT (Intel): - ------------------------------------- http://media.digikey.com/pdf/Data%20Sheets/Intel%20PDFs/IXP42X,%20IXC1100.pdf http://media.digikey.com/pdf/Data%20Sheets/Intel%20PDFs/IXP42X,%20IXC1100%20Spec%20Update%20(Oct-04).pdf - ------------------------------------- PHOTOS - ------------------------------------- http://imageshack.us/a/img856/5395/d0xt.jpg http://imageshack.us/a/img266/8011/x64h.jpg http://imageshack.us/a/img801/9504/0zir.jpg http://imageshack.us/a/img839/4488/sq4r.jpg - ------------------------------------- NMAP SCAN - ------------------------------------- These are the ports available on the LAN side: PORT STATE SERVICE VERSION 22/tcp open ssh Dropbear sshd 0.47 (protocol 2.0) 23/tcp open telnet NASLite-SMB/Sveasoft Alchemy firmware telnetd 53/tcp open domain dnsmasq 2.31 80/tcp open http Boa HTTPd 0.93.15 443/tcp open ssl/http Boa HTTPd 0.93.15 I have already tried a known vuln for Boa HTTPd 0.93.15 to bypass auth, but since the webapp is customized, that flaw is no longer available. At the moment I am trying to bruteforce ssh/telnet, but I guess it would not get any result. Overall, while continuing to disassemble and test it, If someone have some hints or material to share, is welcome. Cheers, Luca -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org iQIcBAEBAgAGBQJR/izEAAoJEPLE1Qsi6ZiTOBYP+wTEeqOYpUxULV24dF8FBu/W ZwL18Dw8zZAp2AEn7C4bGbajH/OAmrTz0Ae0a/jiZCxDEtN7MlF82+9cy8aQvQh/ xMeA3BiA9HlmDKJJO3fsCBoUNXXLIMt4/8F779qPtE2kNRGCkwafVkID93kU2qtA KGUsLeXHZyOzTbxtvwzxwQmAAyna3I2Z4jLzj3O61fpElR2CwFLSokcAqfYp1wNL gw/ofYZhBISqsCn403DMRcZTrfiO8YuqG0I3gdOtrrI2u2UPW3U6OGgtNi3Lz0Gn vLCeS5PMjrhdDKGGEd0IJRZu20QWKJVHUeksQ+fVI6o28TQ84bmvkohkuE8mhzYA rVPzva9+QJbGCHce0+UX3mSjtNl4Tsr1qJ6+useqQaa0KmHLR5SRMEBRAdvMAVQ7 5cgetujabmwyzeNtZECIxZlLmpfscm2ckiSYvnnH4gM3xhS0FZ6i3a5zSCdzCNHT RqFOlBLAUHopS9p5AoAQP5nWqK+xuj3iVWGq++pk6Q/aK7kvMNtlAIpQNhcDN236 9iHloZfeW/eIIBVhtNe6NEuAt4ry8hbeiuGjzJtAR+WAR/PwCtgdEQdOZnLD2LWV FhVNsGySrVvP63gZqhhsW8sUpP8IUaTzoKBgyZ7+fLDoRdqKFVcs+xhqzIfV5dm8 YumNguOR7GwCcAGgBW8g =d+QM -----END PGP SIGNATURE----- From jerlbeck at sysmocom.de Tue Aug 6 12:29:14 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Tue, 6 Aug 2013 14:29:14 +0200 Subject: [PATCH 1/2] vty: Fix misusage of snprintf in vty/utils.c Message-ID: <1375792155-11240-1-git-send-email-jerlbeck@sysmocom.de> Compiled with ubuntu 1204 (precise), where -Wformat-security is enabled by -Wall. Test yields ok, but the current implementation doesn't properly support multi-character separators and end strings. So the test output is truncated. Addresses: utils.c: In function 'vty_cmd_string_from_valstr': utils.c:84:2: warning: format not a string literal and no format arguments [-Wformat-security] utils.c:84:2: warning: format not a string literal and no format arguments [-Wformat-security] utils.c:108:2: warning: format not a string literal and no format arguments [-Wformat-security] utils.c:108:2: warning: format not a string literal and no format arguments [-Wformat-security] --- .gitignore | 1 + src/vty/utils.c | 4 ++-- tests/Makefile.am | 9 +++++-- tests/testsuite.at | 6 +++++ tests/vty/vty_test.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/vty/vty_test.ok | 3 +++ 6 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 tests/vty/vty_test.c create mode 100644 tests/vty/vty_test.ok diff --git a/.gitignore b/.gitignore index 2ed0144..da36165 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,7 @@ tests/fr/fr_test tests/loggingrb/loggingrb_test tests/ringbuf/ringbuf_test tests/strrb/strrb_test +tests/vty/vty_test utils/osmo-arfcn utils/osmo-auc-gen diff --git a/src/vty/utils.c b/src/vty/utils.c index e9c0d2d..88932fa 100644 --- a/src/vty/utils.c +++ b/src/vty/utils.c @@ -81,7 +81,7 @@ char *vty_cmd_string_from_valstr(void *ctx, const struct value_string *vals, if (!str) return NULL; - ret = snprintf(str + offset, rem, prefix); + ret = snprintf(str + offset, rem, "%s", prefix); if (ret < 0) goto err; OSMO_SNPRINTF_RET(ret, rem, offset, len); @@ -105,7 +105,7 @@ char *vty_cmd_string_from_valstr(void *ctx, const struct value_string *vals, offset--; /* to remove the trailing | */ rem++; - ret = snprintf(str + offset, rem, end); + ret = snprintf(str + offset, rem, "%s", end); if (ret < 0) goto err; OSMO_SNPRINTF_RET(ret, rem, offset, len); diff --git a/tests/Makefile.am b/tests/Makefile.am index e5fc718..ecb2b6c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,7 +5,8 @@ check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \ conv/conv_test auth/milenage_test lapd/lapd_test \ gsm0808/gsm0808_test gsm0408/gsm0408_test \ gb/bssgp_fc_test logging/logging_test fr/fr_test \ - loggingrb/loggingrb_test strrb/strrb_test + loggingrb/loggingrb_test strrb/strrb_test \ + vty/vty_test if ENABLE_MSGFILE check_PROGRAMS += msgfile/msgfile_test @@ -62,6 +63,9 @@ loggingrb_loggingrb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_buildd strrb_strrb_test_SOURCES = strrb/strrb_test.c strrb_strrb_test_LDADD = $(top_builddir)/src/libosmocore.la +vty_vty_test_SOURCES = vty/vty_test.c +vty_vty_test_LDADD = $(top_builddir)/src/vty/libosmovty.la $(top_builddir)/src/libosmocore.la + # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac @@ -91,7 +95,8 @@ EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \ msgfile/msgfile_test.ok msgfile/msgconfig.cfg \ logging/logging_test.ok logging/logging_test.err \ fr/fr_test.ok loggingrb/logging_test.ok \ - loggingrb/logging_test.err strrb/strrb_test.ok + loggingrb/logging_test.err strrb/strrb_test.ok \ + vty/vty_test.ok DISTCLEANFILES = atconfig diff --git a/tests/testsuite.at b/tests/testsuite.at index 684ec4f..1a6fa55 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -112,3 +112,9 @@ AT_KEYWORDS([strrb]) cat $abs_srcdir/strrb/strrb_test.ok > expout AT_CHECK([$abs_top_builddir/tests/strrb/strrb_test], [0], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([vty]) +AT_KEYWORDS([vty]) +cat $abs_srcdir/vty/vty_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/vty/vty_test], [0], [expout], [ignore]) +AT_CLEANUP diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c new file mode 100644 index 0000000..6a53fb8 --- /dev/null +++ b/tests/vty/vty_test.c @@ -0,0 +1,62 @@ +/* (C) 2013 by Jacob Erlbeck + * All Rights Reserved + * + * This program is iree software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include + +#include +#include +#include +#include + +static void init_vty(void) +{ +} + +static void free_vty(void) +{ +} + +static void test_cmd_string_from_valstr(void) +{ + char *cmd; + const struct value_string printf_seq_vs[] = { + { .value = 42, .str = "[foo%s%s%s%s%s]"}, + { .value = 43, .str = "[bar%s%s%s%s%s]"}, + { .value = 0, .str = NULL} + }; + + printf("Going to test vty_cmd_string_from_valstr()\n"); + + // check against character strings that could break printf + + cmd = vty_cmd_string_from_valstr (NULL, printf_seq_vs, "[prefix%s%s%s%s%s]", "[sep%s%s%s%s%s]", "[end%s%s%s%s%s]", 1); + printf ("Tested with %%s-strings, resulting cmd = '%s'\n", cmd); + talloc_free (cmd); +} + +int main(int argc, char **argv) +{ + init_vty(); + test_cmd_string_from_valstr(); + printf("All tests passed\n"); + + free_vty(); + return 0; +} diff --git a/tests/vty/vty_test.ok b/tests/vty/vty_test.ok new file mode 100644 index 0000000..9ff68c8 --- /dev/null +++ b/tests/vty/vty_test.ok @@ -0,0 +1,3 @@ +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][' +All tests passed -- 1.7.9.5 From jerlbeck at sysmocom.de Tue Aug 6 12:29:15 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Tue, 6 Aug 2013 14:29:15 +0200 Subject: [PATCH 2/2] vty: Support multi-char separators and end strings In-Reply-To: <1375792155-11240-1-git-send-email-jerlbeck@sysmocom.de> References: <1375792155-11240-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1375792155-11240-2-git-send-email-jerlbeck@sysmocom.de> In vty_cmd_string_from_valstr() include the real string lengths of the sep and end arguments into the buffer size calculation. --- src/vty/utils.c | 9 +++++---- tests/vty/vty_test.ok | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/vty/utils.c b/src/vty/utils.c index 88932fa..fae5c08 100644 --- a/src/vty/utils.c +++ b/src/vty/utils.c @@ -69,12 +69,13 @@ char *vty_cmd_string_from_valstr(void *ctx, const struct value_string *vals, const char *end, int do_lower) { int len = 0, offset = 0, ret, rem; - int size = strlen(prefix); + int size = strlen(prefix) + strlen(end); + int sep_len = strlen(sep); const struct value_string *vs; char *str; for (vs = vals; vs->value || vs->str; vs++) - size += strlen(vs->str) + 1; + size += strlen(vs->str) + sep_len; rem = size; str = talloc_zero_size(ctx, size); @@ -102,8 +103,8 @@ char *vty_cmd_string_from_valstr(void *ctx, const struct value_string *vals, OSMO_SNPRINTF_RET(ret, rem, offset, len); } } - offset--; /* to remove the trailing | */ - rem++; + offset -= sep_len; /* to remove the trailing sep */ + rem += sep_len; ret = snprintf(str + offset, rem, "%s", end); if (ret < 0) diff --git a/tests/vty/vty_test.ok b/tests/vty/vty_test.ok index 9ff68c8..baec249 100644 --- a/tests/vty/vty_test.ok +++ b/tests/vty/vty_test.ok @@ -1,3 +1,3 @@ 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][' +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]' All tests passed -- 1.7.9.5 From holger at freyther.de Tue Aug 6 12:52:44 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 6 Aug 2013 14:52:44 +0200 Subject: [PATCH 1/2] vty: Fix misusage of snprintf in vty/utils.c In-Reply-To: <1375792155-11240-1-git-send-email-jerlbeck@sysmocom.de> References: <1375792155-11240-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130806125244.GA1917@xiaoyu.lan> On Tue, Aug 06, 2013 at 02:29:14PM +0200, Jacob Erlbeck wrote: Hi, thanks for compiling with ubuntu and creating a new test. :) > +/* (C) 2013 by Jacob Erlbeck > + * All Rights Reserved I think you want to use jerlbeck at sysmocom.de and I think something like ... by sysmocom s.f.m.c. Gmbh Author: Jacob Erlbeck is approriate. > +static void init_vty(void) > +static void free_vty(void) we can skip that. :) > + // check against character strings that could break printf that is C99/GNU extension. In general we are using the old C comments with /* */ I will address all of the above before pushinh your patch. From bnt2025 at googlemail.com Tue Aug 6 12:44:33 2013 From: bnt2025 at googlemail.com (Ash Gibbons) Date: Tue, 6 Aug 2013 13:44:33 +0100 Subject: Stopping OpenBSC Message-ID: Bit of a random one, After I start Osmo-NITB is there any way for me to stop the process. I have had a look around the VTY interface, with not much luck. The only way I have found so far is by pressing CTRL+Z in the terminal window, but I then have to restart the computer to be able to start Osmo-NITB again. Many thanks, Ash -------------- next part -------------- An HTML attachment was scrubbed... URL: From 246tnt at gmail.com Tue Aug 6 22:48:01 2013 From: 246tnt at gmail.com (Sylvain Munaut) Date: Wed, 7 Aug 2013 00:48:01 +0200 Subject: Stopping OpenBSC In-Reply-To: References: Message-ID: > After I start Osmo-NITB is there any way for me to stop the process. I have > had a look around the VTY interface, with not much luck. > > The only way I have found so far is by pressing CTRL+Z in the terminal > window, but I then have to restart the computer to be able to start > Osmo-NITB again. CTRL-C From bnt2025 at googlemail.com Wed Aug 7 12:10:24 2013 From: bnt2025 at googlemail.com (Ash Gibbons) Date: Wed, 7 Aug 2013 13:10:24 +0100 Subject: Stopping OpenBSC Message-ID: That's fantastic, thank you. Is there a VTY command to do the same? Many thanks, -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerlbeck at sysmocom.de Thu Aug 8 10:38:52 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 8 Aug 2013 12:38:52 +0200 Subject: [PATCH 1/3] encoding: Provide an overload for the gsm_7bit_encode and a simple test Message-ID: <1375958334-17176-1-git-send-email-jerlbeck@sysmocom.de> From: Holger Hans Peter Freyther This is required for encoding the SMS header using the alpha numeric rules. Reviewed-by: Jacob Erlbeck --- include/osmocom/gsm/gsm_utils.h | 1 + src/gsm/gsm_utils.c | 10 ++++++++-- src/gsm/libosmogsm.map | 1 + tests/sms/sms_test.c | 15 +++++++++++++++ tests/sms/sms_test.ok | 3 +++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index cf63ea4..a572f50 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -59,6 +59,7 @@ enum gsm_band gsm_band_parse(const char *mhz); int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length); int gsm_7bit_decode_hdr(char *decoded, const uint8_t *user_data, uint8_t length, uint8_t ud_hdr_ind); int gsm_7bit_encode(uint8_t *result, const char *data); +int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets_written); /* the three functions below are helper functions and here for the unit test */ int gsm_septets2octets(uint8_t *result, const uint8_t *rdata, uint8_t septet_len, uint8_t padding); diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index 9569cf3..54b965e 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -1,6 +1,6 @@ /* * (C) 2008 by Daniel Willmann - * (C) 2009 by Holger Hans Peter Freyther + * (C) 2009,2013 by Holger Hans Peter Freyther * (C) 2009-2010 by Harald Welte * (C) 2010-2012 by Nico Golde * @@ -250,12 +250,18 @@ int gsm_septets2octets(uint8_t *result, const uint8_t *rdata, uint8_t septet_len /* GSM 03.38 6.2.1 Character packing */ int gsm_7bit_encode(uint8_t *result, const char *data) { + int out; + return gsm_7bit_encode_oct(result, data, &out); +} + +int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets) +{ int y = 0; /* prepare for the worst case, every character expanding to two bytes */ uint8_t *rdata = calloc(strlen(data) * 2, sizeof(uint8_t)); y = gsm_septet_encode(rdata, data); - gsm_septets2octets(result, rdata, y, 0); + *octets = gsm_septets2octets(result, rdata, y, 0); free(rdata); diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index b2278f1..8a020db 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -134,6 +134,7 @@ gsm48_rr_att_tlvdef; gsm_7bit_decode; gsm_7bit_decode_hdr; gsm_7bit_encode; +gsm_7bit_encode_oct; gsm_arfcn2band; gsm_arfcn2freq10; diff --git a/tests/sms/sms_test.c b/tests/sms/sms_test.c index 6df4b62..e48f9a3 100644 --- a/tests/sms/sms_test.c +++ b/tests/sms/sms_test.c @@ -209,6 +209,19 @@ static const struct test_case test_decode[] = }, }; +static void test_octet_return() +{ + char out[256]; + int oct, septets; + + printf("Encoding some tests and printing number of septets/octets\n"); + + septets = gsm_7bit_encode_oct((uint8_t *) out, "test1234", &oct); + printf("SEPTETS: %d OCTETS: %d\n", septets, oct); + + printf("Done\n"); +} + int main(int argc, char** argv) { printf("SMS testing\n"); @@ -314,6 +327,8 @@ int main(int argc, char** argv) } } + test_octet_return(); + printf("OK\n"); return 0; } diff --git a/tests/sms/sms_test.ok b/tests/sms/sms_test.ok index d0e0983..ce6cb17 100644 --- a/tests/sms/sms_test.ok +++ b/tests/sms/sms_test.ok @@ -1,2 +1,5 @@ SMS testing +Encoding some tests and printing number of septets/octets +SEPTETS: 8 OCTETS: 7 +Done OK -- 1.7.9.5 From jerlbeck at sysmocom.de Thu Aug 8 10:38:53 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 8 Aug 2013 12:38:53 +0200 Subject: [PATCH 2/3] Add special 7-bit encoding and decoding functions for USSD coding In-Reply-To: <1375958334-17176-1-git-send-email-jerlbeck@sysmocom.de> References: <1375958334-17176-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1375958334-17176-2-git-send-email-jerlbeck@sysmocom.de> From: Andreas Eversberg Handling 7-bit coding is a little different for USSD, as TS 03.38 states: To avoid the situation where the receiving entity confuses 7 binary zero pad bits as the @ character, the carriage return or character shall be used for padding in this situation [...]. If is intended to be the last character and the message (including the wanted ) ends on an octet boundary, then another must be added together with a padding bit 0. The receiving entity will perform the carriage return function twice, but this will not result in misoperation as the definition of [...] is identical to the definition of . The receiving entity shall remove the final character where the message ends on an octet boundary with as the last character. Jacob has verified the fix with fakeBTS and the wireshark dissector. Fixes: OW#947 Reviewed-by: Jacob Erlbeck --- include/osmocom/gsm/gsm_utils.h | 2 ++ src/gsm/gsm0480.c | 10 +++++----- src/gsm/gsm_utils.c | 31 +++++++++++++++++++++++++++++++ src/gsm/libosmogsm.map | 2 ++ tests/ussd/ussd_test.c | 22 ++++++++++++++++++++++ tests/ussd/ussd_test.ok | 21 +++++++++++++++++++++ 6 files changed, 83 insertions(+), 5 deletions(-) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index a572f50..6cd46e4 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -57,8 +57,10 @@ const char *gsm_band_name(enum gsm_band band); enum gsm_band gsm_band_parse(const char *mhz); int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length); +int gsm_7bit_decode_ussd(char *decoded, const uint8_t *user_data, uint8_t length); int gsm_7bit_decode_hdr(char *decoded, const uint8_t *user_data, uint8_t length, uint8_t ud_hdr_ind); int gsm_7bit_encode(uint8_t *result, const char *data); +int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets_written); int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets_written); /* the three functions below are helper functions and here for the unit test */ diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c index b9b3ed9..cc693fe 100644 --- a/src/gsm/gsm0480.c +++ b/src/gsm/gsm0480.c @@ -105,7 +105,7 @@ struct msgb *gsm0480_create_unstructuredSS_Notify(int alertPattern, const char * msgb_put_u8(msg, ASN1_OCTET_STRING_TAG); ussd_len_ptr = msgb_put(msg, 1); data = msgb_put(msg, 0); - len = gsm_7bit_encode(data, text); + gsm_7bit_encode_ussd(data, text, &len); msgb_put(msg, len); ussd_len_ptr[0] = len; /* USSD-String } */ @@ -172,7 +172,7 @@ struct msgb *gsm0480_create_notifySS(const char *text) msgb_put_u8(msg, 0x82); tmp_len = msgb_put(msg, 1); data = msgb_put(msg, 0); - len = gsm_7bit_encode(data, text); + gsm_7bit_encode_ussd(data, text, &len); tmp_len[0] = len; msgb_put(msg, len); @@ -401,8 +401,8 @@ static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length, /* Prevent a mobile-originated buffer-overrun! */ if (num_chars > MAX_LEN_USSD_STRING) num_chars = MAX_LEN_USSD_STRING; - gsm_7bit_decode(req->text, - &(uss_req_data[7]), num_chars); + gsm_7bit_decode_ussd(req->text, + &(uss_req_data[7]), num_chars); rc = 1; } } @@ -423,7 +423,7 @@ struct msgb *gsm0480_create_ussd_resp(uint8_t invoke_id, uint8_t trans_id, const /* First put the payload text into the message */ ptr8 = msgb_put(msg, 0); - response_len = gsm_7bit_encode(ptr8, text); + gsm_7bit_encode_ussd(ptr8, text, &response_len); msgb_put(msg, response_len); /* Then wrap it as an Octet String */ diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index 54b965e..3dd1537 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -172,6 +172,19 @@ int gsm_7bit_decode(char *text, const uint8_t *user_data, uint8_t septet_l) return gsm_7bit_decode_hdr(text, user_data, septet_l, 0); } +int gsm_7bit_decode_ussd(char *text, const uint8_t *user_data, uint8_t length) +{ + int i; + + gsm_7bit_decode_hdr(text, user_data, length, 0); + i = strlen(text); + /* remove last , if it fits up to the end of last octet */ + if (i && (user_data[gsm_get_octet_len(length) - 1] >> 1) == '\r') + text[--i] = '\0'; + + return i; +} + /* GSM 03.38 6.2.1 Prepare character packing */ int gsm_septet_encode(uint8_t *result, const char *data) { @@ -254,6 +267,24 @@ int gsm_7bit_encode(uint8_t *result, const char *data) return gsm_7bit_encode_oct(result, data, &out); } +int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets) +{ + int y; + + y = gsm_7bit_encode_oct(result, data, octets); + /* if last octet contains only one bit, add */ + if (((y * 7) & 7) == 1) + result[(*octets) - 1] |= ('\r' << 1); + /* if last character is and completely fills last octet, add + * another . */ + if (y && ((y * 7) & 7) == 0 && (result[(*octets) - 1] >> 1) == '\r') { + result[(*octets)++] = '\r'; + y++; + } + + return y; +} + int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets) { int y = 0; diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 8a020db..1b985e1 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -132,8 +132,10 @@ gsm48_parse_ra; gsm48_rr_att_tlvdef; gsm_7bit_decode; +gsm_7bit_decode_ussd; gsm_7bit_decode_hdr; gsm_7bit_encode; +gsm_7bit_encode_ussd; gsm_7bit_encode_oct; gsm_arfcn2band; diff --git a/tests/ussd/ussd_test.c b/tests/ussd/ussd_test.c index 55384f1..d41c141 100644 --- a/tests/ussd/ussd_test.c +++ b/tests/ussd/ussd_test.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,20 @@ static int parse_mangle_ussd(const uint8_t *_data, int len) struct log_info info = {}; +void gsm_7bit_ussd(char *text) +{ + uint8_t coded[256]; + char decoded[256]; + int y; + + printf("original = %s\n", osmo_hexdump((uint8_t *)text, strlen(text))); + gsm_7bit_encode_ussd(coded, text, &y); + printf("encoded = %s\n", osmo_hexdump(coded, y)); + gsm_7bit_decode_ussd(decoded, coded, y * 8 / 7); + y = strlen(decoded); + printf("decoded = %s\n\n", osmo_hexdump((uint8_t *)decoded, y)); +} + int main(int argc, char **argv) { struct ussd_request req; @@ -93,5 +108,12 @@ int main(int argc, char **argv) printf("Result for %d is %d\n", rc, i); } + printf(" case test for 7 bit encode\n"); + gsm_7bit_ussd("01234567"); + gsm_7bit_ussd("0123456"); + gsm_7bit_ussd("01234567\r"); + gsm_7bit_ussd("0123456\r"); + gsm_7bit_ussd("012345\r"); + return 0; } diff --git a/tests/ussd/ussd_test.ok b/tests/ussd/ussd_test.ok index 1b6316e..91f2a31 100644 --- a/tests/ussd/ussd_test.ok +++ b/tests/ussd/ussd_test.ok @@ -51,3 +51,24 @@ Result for 0 is 8 Result for 0 is 7 Result for 0 is 6 Result for 1 is 5 + case test for 7 bit encode +original = 30 31 32 33 34 35 36 37 +encoded = b0 98 6c 46 ab d9 6e +decoded = 30 31 32 33 34 35 36 37 + +original = 30 31 32 33 34 35 36 +encoded = b0 98 6c 46 ab d9 1a +decoded = 30 31 32 33 34 35 36 + +original = 30 31 32 33 34 35 36 37 0d +encoded = b0 98 6c 46 ab d9 6e 0d +decoded = 30 31 32 33 34 35 36 37 0d + +original = 30 31 32 33 34 35 36 0d +encoded = b0 98 6c 46 ab d9 1a 0d +decoded = 30 31 32 33 34 35 36 0d 0d + +original = 30 31 32 33 34 35 0d +encoded = b0 98 6c 46 ab 35 1a +decoded = 30 31 32 33 34 35 0d + -- 1.7.9.5 From jerlbeck at sysmocom.de Thu Aug 8 10:38:54 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 8 Aug 2013 12:38:54 +0200 Subject: [PATCH 3/3] ussd: Changed 7bit test to check spec conformance directly In-Reply-To: <1375958334-17176-1-git-send-email-jerlbeck@sysmocom.de> References: <1375958334-17176-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1375958334-17176-3-git-send-email-jerlbeck@sysmocom.de> Renamed gsm_7bit_ussd() to test_7bit_ussd() and extended the function to take the expected binary encoding and eventually added trailing bytes in the re-decoded text as arguments. These are used to check assertions of the right behaviour instead of solely relying on regression data, because the value are determined by the spec and fixed and it is more obvious this way. Especially concerning the case with the duplicated \r which can easily be overlooked when it's only present in the ok file. --- tests/ussd/ussd_test.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/ussd/ussd_test.c b/tests/ussd/ussd_test.c index d41c141..ffb5440 100644 --- a/tests/ussd/ussd_test.c +++ b/tests/ussd/ussd_test.c @@ -69,7 +69,7 @@ static int parse_mangle_ussd(const uint8_t *_data, int len) struct log_info info = {}; -void gsm_7bit_ussd(char *text) +static void test_7bit_ussd(const char *text, const char *encoded_hex, const char *appended_after_decode) { uint8_t coded[256]; char decoded[256]; @@ -78,9 +78,15 @@ void gsm_7bit_ussd(char *text) printf("original = %s\n", osmo_hexdump((uint8_t *)text, strlen(text))); gsm_7bit_encode_ussd(coded, text, &y); printf("encoded = %s\n", osmo_hexdump(coded, y)); + + OSMO_ASSERT(!strcmp(encoded_hex, osmo_hexdump_nospc(coded, y))); + gsm_7bit_decode_ussd(decoded, coded, y * 8 / 7); y = strlen(decoded); printf("decoded = %s\n\n", osmo_hexdump((uint8_t *)decoded, y)); + + OSMO_ASSERT(!strncmp(text, decoded, strlen (text))); + OSMO_ASSERT(!strcmp(appended_after_decode, decoded + strlen (text))); } int main(int argc, char **argv) @@ -109,11 +115,12 @@ int main(int argc, char **argv) } printf(" case test for 7 bit encode\n"); - gsm_7bit_ussd("01234567"); - gsm_7bit_ussd("0123456"); - gsm_7bit_ussd("01234567\r"); - gsm_7bit_ussd("0123456\r"); - gsm_7bit_ussd("012345\r"); + test_7bit_ussd("01234567", "b0986c46abd96e", ""); + test_7bit_ussd("0123456", "b0986c46abd91a", ""); + test_7bit_ussd("01234567\r", "b0986c46abd96e0d", ""); + /* The appended \r is compliant to GSM 03.38 section 6.1.2.3.1: */ + test_7bit_ussd("0123456\r", "b0986c46abd91a0d", "\r"); + test_7bit_ussd("012345\r", "b0986c46ab351a", ""); return 0; } -- 1.7.9.5 From holger at freyther.de Thu Aug 8 12:21:03 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 8 Aug 2013 14:21:03 +0200 Subject: [PATCH 3/3] ussd: Changed 7bit test to check spec conformance directly In-Reply-To: <1375958334-17176-3-git-send-email-jerlbeck@sysmocom.de> References: <1375958334-17176-1-git-send-email-jerlbeck@sysmocom.de> <1375958334-17176-3-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130808122102.GH29482@xiaoyu.lan> On Thu, Aug 08, 2013 at 12:38:54PM +0200, Jacob Erlbeck wrote: all looks good. thank you for the patches. Some cosmetic nitpick. > + > + OSMO_ASSERT(!strcmp(encoded_hex, osmo_hexdump_nospc(coded, y))); we tend to use strcmp == 0. > + > gsm_7bit_decode_ussd(decoded, coded, y * 8 / 7); > y = strlen(decoded); > printf("decoded = %s\n\n", osmo_hexdump((uint8_t *)decoded, y)); > + > + OSMO_ASSERT(!strncmp(text, decoded, strlen (text))); strlen(text) e.g. no space between the opening parethesis > + OSMO_ASSERT(!strcmp(appended_after_decode, decoded + strlen (text))); I am going to apply all three patches now. From 246tnt at gmail.com Thu Aug 8 13:19:31 2013 From: 246tnt at gmail.com (Sylvain Munaut) Date: Thu, 8 Aug 2013 15:19:31 +0200 Subject: Suspicious code in rtp_send_frame ( libtrau/rtp_proxy.c ) Message-ID: Hi, At each event since like 27c3 (or maybe even 26c3), we comment out a part of the rtp_send_frame method to solve some audio issues (glitch and sometime progressively increasing delay). This is the piece of code in question: { struct timeval tv, tv_diff; long int usec_diff, frame_diff; gettimeofday(&tv, NULL); tv_difference(&tv_diff, &rs->transmit.last_tv, &tv); rs->transmit.last_tv = tv; usec_diff = tv_diff.tv_sec * 1000000 + tv_diff.tv_usec; frame_diff = (usec_diff / 20000); if (abs(frame_diff) > 1) { long int frame_diff_excess = frame_diff - 1; LOGP(DLMUX, LOGL_NOTICE, "Correcting frame difference of %ld frames\n", frame_diff_excess); rs->transmit.sequence += frame_diff_excess; rs->transmit.timestamp += frame_diff_excess * duration; } } introduced by : commit 392736d38bf9dae29800bde630c9ceee8a3914f3 Author: Harald Welte Date: Sun Dec 20 13:16:14 2009 +0100 RTP Proxy: Fix RTP sequence number and timestamp in case of dropped frames During handover, we will not send RTP frames for quite some time. However, the way the rtp_send code is structured, it will increment the timestamp with a fixed amount every time we send a frame, independent how much wallclock time has actually passed. This code is a hack to update the sequence number and timestamp in case it seems to be wrong. It makes handover much more reliable. Does this speak to anyone ? Cheers, Sylvain From andreas at eversberg.eu Thu Aug 8 14:05:09 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Thu, 08 Aug 2013 16:05:09 +0200 Subject: Suspicious code in rtp_send_frame ( libtrau/rtp_proxy.c ) In-Reply-To: References: Message-ID: <5203A595.6030204@eversberg.eu> hi sylvain, Sylvain Munaut wrote: > if (abs(frame_diff) > 1) { > long int frame_diff_excess = frame_diff - 1; > > LOGP(DLMUX, LOGL_NOTICE, > "Correcting frame difference of %ld > frames\n", frame_diff_excess); > rs->transmit.sequence += frame_diff_excess; > rs->transmit.timestamp += frame_diff_excess * duration; > } > ... > This code is a hack to update the sequence number and timestamp in case it > seems to be wrong. It makes handover much more reliable. > > Does this speak to anyone ? > iirc, it is mandatory to maintain sequence/timestamp over time. some RTP endpoints (like nanoBTS) do not like significant change of these sequence numbers and will drop received RTP frames, because they are too much off the expected time then. they actually adapt only slight changes but no big jumps. maybe it makes sense to increase the number of absolute frame difference. with what setup did you have bad audio? regards, andreas From holger at freyther.de Thu Aug 8 14:05:42 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 8 Aug 2013 16:05:42 +0200 Subject: Suspicious code in rtp_send_frame ( libtrau/rtp_proxy.c ) In-Reply-To: References: Message-ID: <20130808140542.GI29482@xiaoyu.lan> On Thu, Aug 08, 2013 at 03:19:31PM +0200, Sylvain Munaut wrote: > Hi, > > > At each event since like 27c3 (or maybe even 26c3), we comment out a > part of the rtp_send_frame method to solve some audio issues (glitch > and sometime progressively increasing delay). I think it should just be removed. holger From laforge at gnumonks.org Wed Aug 14 02:02:31 2013 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 14 Aug 2013 10:02:31 +0800 Subject: Suspicious code in rtp_send_frame ( libtrau/rtp_proxy.c ) In-Reply-To: <20130808140542.GI29482@xiaoyu.lan> References: <20130808140542.GI29482@xiaoyu.lan> Message-ID: <20130814020231.GC6245@nataraja.gnumonks.org> Hi Holger and Sylvain, On Thu, Aug 08, 2013 at 04:05:42PM +0200, Holger Hans Peter Freyther wrote: > > At each event since like 27c3 (or maybe even 26c3), we comment out a > > part of the rtp_send_frame method to solve some audio issues (glitch > > and sometime progressively increasing delay). > > I think it should just be removed. As far as I know, if it is removed, then it will break hand-over support for nanoBTS (for reasons that Andreas has just pointed out). So that should be verified (or the code made conditional?) 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 246tnt at gmail.com Wed Aug 14 09:13:54 2013 From: 246tnt at gmail.com (Sylvain Munaut) Date: Wed, 14 Aug 2013 11:13:54 +0200 Subject: Suspicious code in rtp_send_frame ( libtrau/rtp_proxy.c ) In-Reply-To: <20130814020231.GC6245@nataraja.gnumonks.org> References: <20130808140542.GI29482@xiaoyu.lan> <20130814020231.GC6245@nataraja.gnumonks.org> Message-ID: Hi, > As far as I know, if it is removed, then it will break hand-over support > for nanoBTS (for reasons that Andreas has just pointed out). So that > should be verified (or the code made conditional?) Well, if it's required for handover, making it optional wouldn't help much. At theses events we'd probably want handover once it's supported/working. I think the main issue is that this code is way too strict. It just shouldn't be triggered unless there is a big discontinuity. During the execution we can see the message that it corrected 1 or 2 frames, but that's probably just because of our delay in processing frames and/or due to small difference in clock rate between the device and the openbsc machine. In both of theses cases, the receiving device should handle that itself. AFAIU a handover would be a massive jump of timestamp. We might also be able to detect that the source of the stream changed and only resync in that case. Is there any handover setup that's supported / working with the HEAD code so that I could try locally ? (I never even tried handover anywhere beforce ...) Cheers, Sylvain From laforge at gnumonks.org Wed Aug 14 10:06:46 2013 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 14 Aug 2013 18:06:46 +0800 Subject: Suspicious code in rtp_send_frame ( libtrau/rtp_proxy.c ) In-Reply-To: References: <20130808140542.GI29482@xiaoyu.lan> <20130814020231.GC6245@nataraja.gnumonks.org> Message-ID: <20130814100646.GE6548@nataraja.gnumonks.org> Hi Sylvain, On Wed, Aug 14, 2013 at 11:13:54AM +0200, Sylvain Munaut wrote: > AFAIU a handover would be a massive jump of timestamp. We might also > be able to detect that the source of the stream changed and only > resync in that case. agreed. > Is there any handover setup that's supported / working with the HEAD > code so that I could try locally ? (I never even tried handover > anywhere beforce ...) it _should_ work with current master/HEAD out-of-the box, just use OsmoNITB with two nanoBTS (if you have them...), activate the rtp proxy by command line switch, establish a voice call and then either manually trigger a handover with the VTY command for it, or use something like a variable/switchable attenuator to trigger the HO algorithm. 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 andreas at eversberg.eu Wed Aug 14 11:19:48 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Wed, 14 Aug 2013 13:19:48 +0200 Subject: Suspicious code in rtp_send_frame ( libtrau/rtp_proxy.c ) In-Reply-To: <20130814100646.GE6548@nataraja.gnumonks.org> References: <20130808140542.GI29482@xiaoyu.lan> <20130814020231.GC6245@nataraja.gnumonks.org> <20130814100646.GE6548@nataraja.gnumonks.org> Message-ID: <520B67D4.4000309@eversberg.eu> Harald Welte wrote: > it _should_ work with current master/HEAD out-of-the box, just use > OsmoNITB with two nanoBTS (if you have them...), activate the rtp proxy > by command line switch, establish a voice call and then either manually > trigger a handover with the VTY command for it, or use something like a > variable/switchable attenuator to trigger the HO algorithm. > it is actually working out of the box with nanobts. only required is one bts, because handover can be triggered via vty (subscr exten xxxx handover 0). because handover requires a different channel, it will start with a new rtp stream, so sequence numbers should be different. handover works with umtrx and calypso-bts (osmo-bts), but not from master. From laforge at gnumonks.org Wed Aug 14 13:07:28 2013 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 14 Aug 2013 21:07:28 +0800 Subject: Suspicious code in rtp_send_frame ( libtrau/rtp_proxy.c ) In-Reply-To: <520B67D4.4000309@eversberg.eu> References: <20130808140542.GI29482@xiaoyu.lan> <20130814020231.GC6245@nataraja.gnumonks.org> <20130814100646.GE6548@nataraja.gnumonks.org> <520B67D4.4000309@eversberg.eu> Message-ID: <20130814130728.GI6548@nataraja.gnumonks.org> Hi Andreas, On Wed, Aug 14, 2013 at 01:19:48PM +0200, Andreas Eversberg wrote: > it is actually working out of the box with nanobts. only required is one > bts, because handover can be triggered via vty (subscr exten xxxx > handover 0). because handover requires a different channel, it will > start with a new rtp stream, so sequence numbers should be different. That's exactly the reason why I specifically asked for two nanoBTS. The timing behavior of handing over between two channels on the same BTS is not realistic, as both channels are clocked by the same master clock, and thus do not have unsynchronized timing behavior. Yes, the SSRC _might_ jump (technically the RTP specs would not require it in this case), but afther that one jump it would have exactly the same timing as before the HO - unlike the case where you hand-over to another BTS. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From jolly at eversberg.eu Fri Aug 9 11:33:13 2013 From: jolly at eversberg.eu (Andreas Eversberg) Date: Fri, 9 Aug 2013 13:33:13 +0200 Subject: [PATCH] Fix: Use gsm_7bit_encode_ussd function to encode USSD response Message-ID: <1376047993-20410-1-git-send-email-jolly@eversberg.eu> The New function offers the actual octet that is needed to correctly compose USSD response. --- openbsc/src/libmsc/gsm_04_80.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/openbsc/src/libmsc/gsm_04_80.c b/openbsc/src/libmsc/gsm_04_80.c index 39738a5..1b1c449 100644 --- a/openbsc/src/libmsc/gsm_04_80.c +++ b/openbsc/src/libmsc/gsm_04_80.c @@ -72,7 +72,7 @@ int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn, /* First put the payload text into the message */ ptr8 = msgb_put(msg, 0); - response_len = gsm_7bit_encode(ptr8, response_text); + gsm_7bit_encode_ussd(ptr8, response_text, &response_len); msgb_put(msg, response_len); /* Then wrap it as an Octet String */ -- 1.7.3.4 From holger at freyther.de Fri Aug 9 15:35:40 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 9 Aug 2013 17:35:40 +0200 Subject: [PATCH] Fix: Use gsm_7bit_encode_ussd function to encode USSD response In-Reply-To: <1376047993-20410-1-git-send-email-jolly@eversberg.eu> References: <1376047993-20410-1-git-send-email-jolly@eversberg.eu> Message-ID: <20130809153540.GE4254@xiaoyu.lan> On Fri, Aug 09, 2013 at 01:33:13PM +0200, Andreas Eversberg wrote: > The New function offers the actual octet that is needed to correctly > compose USSD response. not yet. You should wait until a libosmocore release and then bump the requirement of libosmocore in the configure.ac From msdaudi at gmail.com Sun Aug 11 07:12:09 2013 From: msdaudi at gmail.com (Daud Suleiman) Date: Sun, 11 Aug 2013 10:12:09 +0300 Subject: MultiCarrier with UmTRX + OsmoBTS Message-ID: Hi, Is MultiCarrier operation possible with the UmTRX in combination either OsmoBTS? On another note, is it possible for the outbound MNCC interface to pass call control to a standard SIP softswitch (kamaillio?) without going through LCR? -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter at stuge.se Sun Aug 11 17:16:35 2013 From: peter at stuge.se (Peter Stuge) Date: Sun, 11 Aug 2013 19:16:35 +0200 Subject: MultiCarrier with UmTRX + OsmoBTS In-Reply-To: References: Message-ID: <20130811171635.11684.qmail@stuge.se> Daud Suleiman wrote: > Is MultiCarrier operation possible with the UmTRX in combination either > OsmoBTS? I'm not sure I understand this question. It does not seem to have anything to do with OpenBSC so probably you should ask it elsewhere. > On another note, is it possible for the outbound MNCC interface to > pass call control to a standard SIP softswitch (kamaillio?) without > going through LCR? Not unless a standard SIP softswitch implements support for the OpenBSC MNCC interface. I don't think that they will. Why don't you just use LCR? It works fine. If you are determined not to learn anything on your own you can use http://stuge.se/lcr.txt for cheating. //Peter From alexander.chemeris at gmail.com Mon Aug 12 13:32:27 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Mon, 12 Aug 2013 17:32:27 +0400 Subject: MultiCarrier with UmTRX + OsmoBTS In-Reply-To: <20130811171635.11684.qmail@stuge.se> References: <20130811171635.11684.qmail@stuge.se> Message-ID: On Sun, Aug 11, 2013 at 9:16 PM, Peter Stuge wrote: > Daud Suleiman wrote: >> Is MultiCarrier operation possible with the UmTRX in combination either >> OsmoBTS? > > I'm not sure I understand this question. It does not seem to have > anything to do with OpenBSC so probably you should ask it elsewhere. I think this e-mail list is fine for discussions of OsmoBTS, as it's a part of the same software suite and doesn't have a separate mailing list. Correct me if I'm wrong. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From alexander.chemeris at gmail.com Mon Aug 12 12:25:35 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Mon, 12 Aug 2013 16:25:35 +0400 Subject: MultiCarrier with UmTRX + OsmoBTS In-Reply-To: References: Message-ID: Daud, On Sun, Aug 11, 2013 at 11:12 AM, Daud Suleiman wrote: > Is MultiCarrier operation possible with the UmTRX in combination either > OsmoBTS? Yes, OsmoBTS supports multi-trx operation. Note, though, that multi-carrier transceiver is in beta stage at this moment. > On another note, is it possible for the outbound MNCC interface to > pass call control to a standard SIP softswitch (kamaillio?) without going > through LCR? Someone on IRC wrote a plugin for Asterisk to speak MNCC, but it is not published to public yet. We're planning to extend this to support Freeeswitch or to write a completely separate A-to-SIP gateway, but these are just plans at this moment. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From andreas at eversberg.eu Mon Aug 12 08:12:08 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Mon, 12 Aug 2013 10:12:08 +0200 Subject: Channel allocation stress-test Message-ID: <520898D8.6020406@eversberg.eu> dear holger, i tried your channel allocation stress-test patch for openbsc with osmo-bts-trx. i had no crashes, but it helped me to find a bug in the scheduler. i remember that there was an issue that causes a crash of osmo-bts (sysmobts, trx ?), but i am not sure. if so, can you give me a hint, which test procedure caused a crash? regards, andreas From holger at freyther.de Mon Aug 12 14:41:22 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 12 Aug 2013 16:41:22 +0200 Subject: Channel allocation stress-test In-Reply-To: <520898D8.6020406@eversberg.eu> References: <520898D8.6020406@eversberg.eu> Message-ID: <20130812144122.GB30342@xiaoyu.lan> On Mon, Aug 12, 2013 at 10:12:08AM +0200, Andreas Eversberg wrote: > dear holger, > > i tried your channel allocation stress-test patch for openbsc with > osmo-bts-trx. i had no crashes, but it helped me to find a bug in the > scheduler. i remember that there was an issue that causes a crash of > osmo-bts (sysmobts, trx ?), but i am not sure. if so, can you give me a > hint, which test procedure caused a crash? Allocating all channels with the sysmobts was enough to provoke the crash. I am happy that my stress-testing branch exposed a defect that you were able to resolve. In terms of reviewing and merging your sap patches, the only way forward is to make them as small as possible and incrementally, and one should avoid methods with hundreds of lines of codes. holger > > From jerlbeck at sysmocom.de Mon Aug 12 12:08:17 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 12 Aug 2013 14:08:17 +0200 Subject: [PATCH 1/2] sms: Added result buffer size parameter to 7bit conv funs Message-ID: <1376309298-9472-1-git-send-email-jerlbeck@sysmocom.de> The 7bit<->8bit encoding/decoding functions didn't check whether there is still enough space in the destination buffer. Therefore a buffer size parameter ('n' like in snprintf) has been added to each of the functions which leads to truncation if the the buffer is too small. In addition, the return value of the decoding functions has been changed to number of characters written (excluding \0), so this value is always equal to strlen(decoded) if n>0. The old functions are still available as wrapper functions. --- include/osmocom/gsm/gsm_utils.h | 63 ++++++++++++++++-- src/gsm/gsm0480.c | 11 ++-- src/gsm/gsm_utils.c | 137 +++++++++++++++++++++++++-------------- src/gsm/libosmogsm.map | 7 +- tests/sms/sms_test.c | 128 ++++++++++++++++++++---------------- tests/sms/sms_test.ok | 10 +++ tests/ussd/ussd_test.c | 38 +++++++++-- 7 files changed, 268 insertions(+), 126 deletions(-) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 6cd46e4..bdb4c74 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -25,6 +25,7 @@ #ifndef GSM_UTILS_H #define GSM_UTILS_H +#include #include #define ADD_MODULO(sum, delta, modulo) do { \ @@ -56,17 +57,58 @@ enum gsm_band { const char *gsm_band_name(enum gsm_band band); enum gsm_band gsm_band_parse(const char *mhz); -int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length); -int gsm_7bit_decode_ussd(char *decoded, const uint8_t *user_data, uint8_t length); -int gsm_7bit_decode_hdr(char *decoded, const uint8_t *user_data, uint8_t length, uint8_t ud_hdr_ind); -int gsm_7bit_encode(uint8_t *result, const char *data); -int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets_written); -int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets_written); +/* + * The following functions write at most n octets to the destination buffer + * ('decoded' or 'result') and return the number of octets written (always + * <= n). + */ + +/*! + * \brief Decode a sequence of GSM 03.38 encoded 7 bit characters. + * + * \param decoded The destination buffer for the decoded characters. + * \param n A maximum of n chars is written (incl. \0). + * \param user_data A pointer to the start of the packed 7bit character + * sequence. + * \param length The length of the input sequence (in octets). + * + * \returns the number of (8 bit) chars written excluding the terminating \0. + */ +int gsm_7bit_decode_n(char *decoded, size_t n, const uint8_t *user_data, uint8_t length); + +/*! + * \brief Decode a sequence of 7 bit characters (USSD encoding). + * + * \see gsm_7bit_encode_n() + */ +int gsm_7bit_decode_n_ussd(char *decoded, size_t n, const uint8_t *user_data, uint8_t length); -/* the three functions below are helper functions and here for the unit test */ +/** + * \brief Encode a text string into GSM 03.38 encoded 7 bit characters. + * + * \param result The destination buffer for the packed 7 bit sequence. + * \param n A maximum of n octets is written. + * \param data A pointer to the start of the \0 terminated 8 bit character + * string. + * \param octets_written Iff not NULL, *octets_written will be set to the + * number of octets written to the result buffer. + * + * \returns the number of septets that have been created. + */ +int gsm_7bit_encode_n(uint8_t *result, size_t n, const char *data, int *octets_written); + +/*! + * \brief Encode a text string into GSM 03.38 encoded 7 bit characters (USSD encoding). + * + * \see gsm_7bit_decode_n() + */ +int gsm_7bit_encode_n_ussd(uint8_t *result, size_t n, const char *data, int *octets_written); + +/* the four functions below are helper functions and here for the unit test */ int gsm_septets2octets(uint8_t *result, const uint8_t *rdata, uint8_t septet_len, uint8_t padding); int gsm_septet_encode(uint8_t *result, const char *data); uint8_t gsm_get_octet_len(const uint8_t sept_len); +int gsm_7bit_decode_n_hdr(char *decoded, size_t n, const uint8_t *user_data, uint8_t length, uint8_t ud_hdr_ind); unsigned int ms_class_gmsk_dbm(enum gsm_band band, int ms_class); @@ -154,5 +196,12 @@ enum gsm_chan_t { _GSM_LCHAN_MAX }; +/* Deprectated functions */ +int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length) __attribute__((deprecated ("Use gsm_7bit_decode_n() instead"))); +int gsm_7bit_decode_ussd(char *decoded, const uint8_t *user_data, uint8_t length) __attribute__((deprecated ("Use gsm_7bit_decode_n_ussd() instead"))); +int gsm_7bit_encode(uint8_t *result, const char *data) __attribute__((deprecated ("Use gsm_7bit_encode_n() instead"))); +int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets_written) __attribute__((deprecated ("Use gsm_7bit_encode_n_ussd() instead"))); +int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets_written) __attribute__((deprecated ("Use gsm_7bit_encode_n() instead"))); + #endif diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c index cc693fe..0f72593 100644 --- a/src/gsm/gsm0480.c +++ b/src/gsm/gsm0480.c @@ -105,7 +105,7 @@ struct msgb *gsm0480_create_unstructuredSS_Notify(int alertPattern, const char * msgb_put_u8(msg, ASN1_OCTET_STRING_TAG); ussd_len_ptr = msgb_put(msg, 1); data = msgb_put(msg, 0); - gsm_7bit_encode_ussd(data, text, &len); + gsm_7bit_encode_n_ussd(data, msgb_tailroom(msg), text, &len); msgb_put(msg, len); ussd_len_ptr[0] = len; /* USSD-String } */ @@ -172,7 +172,7 @@ struct msgb *gsm0480_create_notifySS(const char *text) msgb_put_u8(msg, 0x82); tmp_len = msgb_put(msg, 1); data = msgb_put(msg, 0); - gsm_7bit_encode_ussd(data, text, &len); + gsm_7bit_encode_n_ussd(data, msgb_tailroom(msg), text, &len); tmp_len[0] = len; msgb_put(msg, len); @@ -398,10 +398,7 @@ static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length, if ((dcs == 0x0F) && (uss_req_data[5] == ASN1_OCTET_STRING_TAG)) { num_chars = (uss_req_data[6] * 8) / 7; - /* Prevent a mobile-originated buffer-overrun! */ - if (num_chars > MAX_LEN_USSD_STRING) - num_chars = MAX_LEN_USSD_STRING; - gsm_7bit_decode_ussd(req->text, + gsm_7bit_decode_n_ussd(req->text, sizeof (req->text), &(uss_req_data[7]), num_chars); rc = 1; } @@ -423,7 +420,7 @@ struct msgb *gsm0480_create_ussd_resp(uint8_t invoke_id, uint8_t trans_id, const /* First put the payload text into the message */ ptr8 = msgb_put(msg, 0); - gsm_7bit_encode_ussd(ptr8, text, &response_len); + gsm_7bit_encode_n_ussd(ptr8, msgb_tailroom(msg), text, &response_len); msgb_put(msg, response_len); /* Then wrap it as an Octet String */ diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index 3dd1537..d76a5f2 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -123,12 +123,18 @@ uint8_t gsm_get_octet_len(const uint8_t sept_len){ } /* GSM 03.38 6.2.1 Character unpacking */ -int gsm_7bit_decode_hdr(char *text, const uint8_t *user_data, uint8_t septet_l, uint8_t ud_hdr_ind) +int gsm_7bit_decode_n_hdr(char *text, size_t n, const uint8_t *user_data, uint8_t septet_l, uint8_t ud_hdr_ind) { int i = 0; int shift = 0; - uint8_t c; + uint8_t c7, c8; uint8_t next_is_ext = 0; + const char *text_buf_begin = text; + const char *text_buf_end = text + n; + int nchars; + + if (n == 0) + return 0; /* skip the user data header */ if (ud_hdr_ind) { @@ -139,50 +145,49 @@ int gsm_7bit_decode_hdr(char *text, const uint8_t *user_data, uint8_t septet_l, septet_l = septet_l - shift; } - for (i = 0; i < septet_l; i++) { - c = + for (i = 0; i < septet_l && text != text_buf_end - 1; i++) { + c7 = ((user_data[((i + shift) * 7 + 7) >> 3] << (7 - (((i + shift) * 7 + 7) & 7))) | (user_data[((i + shift) * 7) >> 3] >> (((i + shift) * 7) & 7))) & 0x7f; - /* this is an extension character */ if (next_is_ext) { + /* this is an extension character */ next_is_ext = 0; - *(text++) = gsm_7bit_alphabet[0x7f + c]; - continue; - } - - if (c == 0x1b && i + 1 < septet_l) { + c8 = gsm_7bit_alphabet[0x7f + c7]; + } else if (c7 == 0x1b && i + 1 < septet_l) { next_is_ext = 1; + continue; } else { - *(text++) = gsm_septet_lookup(c); + c8 = gsm_septet_lookup(c7); } + + *(text++) = c8; } - if (ud_hdr_ind) - i += shift; + nchars = (int)text - (int)text_buf_begin; + *text = '\0'; - return i; + return nchars; } -int gsm_7bit_decode(char *text, const uint8_t *user_data, uint8_t septet_l) +int gsm_7bit_decode_n(char *text, size_t n, const uint8_t *user_data, uint8_t septet_l) { - return gsm_7bit_decode_hdr(text, user_data, septet_l, 0); + return gsm_7bit_decode_n_hdr(text, n, user_data, septet_l, 0); } -int gsm_7bit_decode_ussd(char *text, const uint8_t *user_data, uint8_t length) +int gsm_7bit_decode_n_ussd(char *text, size_t n, const uint8_t *user_data, uint8_t length) { - int i; + int nchars; - gsm_7bit_decode_hdr(text, user_data, length, 0); - i = strlen(text); + nchars = gsm_7bit_decode_n_hdr(text, n, user_data, length, 0); /* remove last , if it fits up to the end of last octet */ - if (i && (user_data[gsm_get_octet_len(length) - 1] >> 1) == '\r') - text[--i] = '\0'; + if (nchars && (user_data[gsm_get_octet_len(length) - 1] >> 1) == '\r') + text[--nchars] = '\0'; - return i; + return nchars; } /* GSM 03.38 6.2.1 Prepare character packing */ @@ -261,38 +266,23 @@ int gsm_septets2octets(uint8_t *result, const uint8_t *rdata, uint8_t septet_len } /* GSM 03.38 6.2.1 Character packing */ -int gsm_7bit_encode(uint8_t *result, const char *data) -{ - int out; - return gsm_7bit_encode_oct(result, data, &out); -} - -int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets) -{ - int y; - - y = gsm_7bit_encode_oct(result, data, octets); - /* if last octet contains only one bit, add */ - if (((y * 7) & 7) == 1) - result[(*octets) - 1] |= ('\r' << 1); - /* if last character is and completely fills last octet, add - * another . */ - if (y && ((y * 7) & 7) == 0 && (result[(*octets) - 1] >> 1) == '\r') { - result[(*octets)++] = '\r'; - y++; - } - - return y; -} - -int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets) +int gsm_7bit_encode_n(uint8_t *result, size_t n, const char *data, int *octets) { int y = 0; + int o; + int max_septets = n * 8 / 7; /* prepare for the worst case, every character expanding to two bytes */ uint8_t *rdata = calloc(strlen(data) * 2, sizeof(uint8_t)); y = gsm_septet_encode(rdata, data); - *octets = gsm_septets2octets(result, rdata, y, 0); + + if (y > max_septets) + y = max_septets; + + o = gsm_septets2octets(result, rdata, y, 0); + + if (octets) + *octets = o; free(rdata); @@ -309,6 +299,24 @@ int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets) return y; } +int gsm_7bit_encode_n_ussd(uint8_t *result, size_t n, const char *data, int *octets) +{ + int y; + + y = gsm_7bit_encode_n(result, n, data, octets); + /* if last octet contains only one bit, add */ + if (((y * 7) & 7) == 1) + result[(*octets) - 1] |= ('\r' << 1); + /* if last character is and completely fills last octet, add + * another . */ + if (y && ((y * 7) & 7) == 0 && (result[(*octets) - 1] >> 1) == '\r' && *octets < n - 1) { + result[(*octets)++] = '\r'; + y++; + } + + return y; +} + /* convert power class to dBm according to GSM TS 05.05 */ unsigned int ms_class_gmsk_dbm(enum gsm_band band, int class) { @@ -662,3 +670,34 @@ uint32_t gprs_tmsi2tlli(uint32_t p_tmsi, enum gprs_tlli_type type) } return tlli; } + +/* Wrappers for deprecated functions: */ + +int gsm_7bit_decode(char *text, const uint8_t *user_data, uint8_t septet_l) +{ + gsm_7bit_decode_n(text, SIZE_MAX, user_data, septet_l); + + /* Mimic the original behaviour. */ + return septet_l; +} + +int gsm_7bit_decode_ussd(char *text, const uint8_t *user_data, uint8_t length) +{ + return gsm_7bit_decode_n_ussd(text, SIZE_MAX, user_data, length); +} + +int gsm_7bit_encode(uint8_t *result, const char *data) +{ + int out; + return gsm_7bit_encode_n(result, SIZE_MAX, data, &out); +} + +int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets) +{ + return gsm_7bit_encode_n_ussd(result, SIZE_MAX, data, octets); +} + +int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets) +{ + return gsm_7bit_encode_n(result, SIZE_MAX, data, octets); +} diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 1b985e1..9d15d66 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -133,11 +133,16 @@ gsm48_rr_att_tlvdef; gsm_7bit_decode; gsm_7bit_decode_ussd; -gsm_7bit_decode_hdr; gsm_7bit_encode; gsm_7bit_encode_ussd; gsm_7bit_encode_oct; +gsm_7bit_decode_n; +gsm_7bit_decode_n_ussd; +gsm_7bit_decode_n_hdr; +gsm_7bit_encode_n; +gsm_7bit_encode_n_ussd; + gsm_arfcn2band; gsm_arfcn2freq10; gsm_freq102arfcn; diff --git a/tests/sms/sms_test.c b/tests/sms/sms_test.c index e48f9a3..c0f5bf6 100644 --- a/tests/sms/sms_test.c +++ b/tests/sms/sms_test.c @@ -116,14 +116,14 @@ static const uint8_t concatenated_part2_enc[] = { static const struct test_case test_multiple_encode[] = { { - .input = concatenated_text, + .input = (const uint8_t *)concatenated_text, .expected = concatenated_part1_enc, .expected_octet_length = sizeof(concatenated_part1_enc), .expected_septet_length = concatenated_part1_septet_length, .ud_hdr_ind = 1, }, { - .input = concatenated_text, + .input = (const uint8_t *)concatenated_text, .expected = concatenated_part2_enc, .expected_octet_length = sizeof(concatenated_part2_enc), .expected_septet_length = concatenated_part2_septet_length, @@ -134,28 +134,28 @@ static const struct test_case test_multiple_encode[] = static const struct test_case test_encode[] = { { - .input = simple_text, + .input = (const uint8_t *)simple_text, .expected = simple_enc, .expected_octet_length = sizeof(simple_enc), .expected_septet_length = simple_septet_length, .ud_hdr_ind = 0, }, { - .input = escape_text, + .input = (const uint8_t *)escape_text, .expected = escape_enc, .expected_octet_length = sizeof(escape_enc), .expected_septet_length = escape_septet_length, .ud_hdr_ind = 0, }, { - .input = enhanced_text, + .input = (const uint8_t *)enhanced_text, .expected = enhanced_enc, .expected_octet_length = sizeof(enhanced_enc), .expected_septet_length = enhanced_septet_length, .ud_hdr_ind = 0, }, { - .input = enhancedV2_text, + .input = (const uint8_t *)enhancedV2_text, .expected = enhancedV2_enc, .expected_octet_length = sizeof(enhancedV2_enc), .expected_septet_length = enhancedV2_septet_length, @@ -168,42 +168,42 @@ static const struct test_case test_decode[] = { .input = simple_enc, .input_length = sizeof(simple_enc), - .expected = simple_text, + .expected = (const uint8_t *)simple_text, .expected_septet_length = simple_septet_length, .ud_hdr_ind = 0, }, { .input = escape_enc, .input_length = sizeof(escape_enc), - .expected = escape_text, + .expected = (const uint8_t *)escape_text, .expected_septet_length = escape_septet_length, .ud_hdr_ind = 0, }, { .input = enhanced_enc, .input_length = sizeof(enhanced_enc), - .expected = enhanced_text, + .expected = (const uint8_t *)enhanced_text, .expected_septet_length = enhanced_septet_length, .ud_hdr_ind = 0, }, { .input = enhancedV2_enc, .input_length = sizeof(enhancedV2_enc), - .expected = enhancedV2_text, + .expected = (const uint8_t *)enhancedV2_text, .expected_septet_length = enhancedV2_septet_length, .ud_hdr_ind = 0, }, { .input = concatenated_part1_enc, .input_length = sizeof(concatenated_part1_enc), - .expected = splitted_text_part1, + .expected = (const uint8_t *)splitted_text_part1, .expected_septet_length = concatenated_part1_septet_length_with_header, .ud_hdr_ind = 1, }, { .input = concatenated_part2_enc, .input_length = sizeof(concatenated_part2_enc), - .expected = splitted_text_part2, + .expected = (const uint8_t *)splitted_text_part2, .expected_septet_length = concatenated_part2_septet_length_with_header, .ud_hdr_ind = 1, }, @@ -216,7 +216,7 @@ static void test_octet_return() printf("Encoding some tests and printing number of septets/octets\n"); - septets = gsm_7bit_encode_oct((uint8_t *) out, "test1234", &oct); + septets = gsm_7bit_encode_n((uint8_t *) out, sizeof(out), "test1234", &oct); printf("SEPTETS: %d OCTETS: %d\n", septets, oct); printf("Done\n"); @@ -227,43 +227,58 @@ int main(int argc, char** argv) printf("SMS testing\n"); struct msgb *msg; uint8_t i; - + uint16_t buffer_size; uint8_t octet_length; + int octets_written; + uint8_t computed_octet_length; uint8_t septet_length; uint8_t gsm_septet_length; uint8_t coded[256]; uint8_t tmp[160]; uint8_t septet_data[256]; uint8_t ud_header[6]; + int nchars; char result[256]; /* test 7-bit encoding */ for (i = 0; i < ARRAY_SIZE(test_encode); ++i) { memset(coded, 0x42, sizeof(coded)); - septet_length = gsm_7bit_encode(coded, test_encode[i].input); - octet_length = gsm_get_octet_len(septet_length); - if (octet_length != test_encode[i].expected_octet_length) { - fprintf(stderr, "Encode case %d: Octet length failure. Got %d, expected %d\n", - i, octet_length, test_encode[i].expected_octet_length); - return -1; - } - - if (septet_length != test_encode[i].expected_septet_length){ - fprintf(stderr, "Encode case %d: Septet length failure. Got %d, expected %d\n", - i, septet_length, test_encode[i].expected_septet_length); - return -1; - } - - if (memcmp(coded, test_encode[i].expected, octet_length) != 0) { - fprintf(stderr, "Encoded content does not match for case %d\n", - i); - return -1; + septet_length = gsm_7bit_encode_n(coded, sizeof(coded), + (const char *)test_encode[i].input, + &octets_written); + computed_octet_length = gsm_get_octet_len(septet_length); + printf("Encode case %d: " + "Octet length %d (expected %d, computed %d), " + "septet length %d (expected %d)\n" + , i + , octets_written, test_encode[i].expected_octet_length, computed_octet_length + , septet_length, test_encode[i].expected_septet_length + ); + + OSMO_ASSERT (octets_written == test_encode[i].expected_octet_length); + OSMO_ASSERT (octets_written == computed_octet_length); + OSMO_ASSERT (memcmp(coded, test_encode[i].expected, octets_written) == 0); + + /* check buffer limiting */ + memset(coded, 0xaa, sizeof(coded)); + + for (buffer_size = 0; + buffer_size < test_encode[i].expected_octet_length + 1 + && buffer_size < sizeof(coded) - 1; + ++buffer_size) + { + gsm_7bit_encode_n(coded, buffer_size, + (const char *)test_encode[i].input, + &octets_written); + + OSMO_ASSERT(octets_written <= buffer_size); + OSMO_ASSERT(coded[buffer_size] == 0xaa); } } /* Test: encode multiple SMS */ - int number_of_septets = gsm_septet_encode(septet_data, test_multiple_encode[0].input); + int number_of_septets = gsm_septet_encode(septet_data, (const char *)test_multiple_encode[0].input); /* SMS part 1 */ memset(tmp, 0x42, sizeof(tmp)); @@ -281,11 +296,7 @@ int main(int argc, char** argv) memset(coded, 0x42, sizeof(coded)); memcpy(coded, tmp, octet_length + 6); - if (memcmp(coded, test_multiple_encode[0].expected, octet_length) != 0) { - fprintf(stderr, "Multiple-SMS encoded content does not match for part 1\n"); - return -1; - } - + OSMO_ASSERT(memcmp(coded, test_multiple_encode[0].expected, octet_length) == 0); /* SMS part 2 */ memset(tmp, 0x42, sizeof(tmp)); @@ -303,27 +314,34 @@ int main(int argc, char** argv) memset(coded, 0x42, sizeof(coded)); memcpy(coded, tmp, octet_length + 6); - if (memcmp(coded, test_multiple_encode[1].expected, octet_length) != 0) { - fprintf(stderr, "Multiple-SMS encoded content does not match for part 2\n"); - return -1; - } - - + OSMO_ASSERT(memcmp(coded, test_multiple_encode[1].expected, octet_length) == 0); /* test 7-bit decoding */ for (i = 0; i < ARRAY_SIZE(test_decode); ++i) { - memset(result, 0x42, sizeof(coded)); - septet_length = gsm_7bit_decode_hdr(result, test_decode[i].input, + memset(result, 0x42, sizeof(result)); + nchars = gsm_7bit_decode_n_hdr(result, sizeof(result), test_decode[i].input, test_decode[i].expected_septet_length, test_decode[i].ud_hdr_ind); - - if (strcmp(result, test_decode[i].expected) != 0) { - fprintf(stderr, "Test case %d failed to decode.\n", i); - return -1; - } - if (septet_length != test_decode[i].expected_septet_length) { - fprintf(stderr, "Decode case %d: Septet length failure. Got %d, expected %d\n", - i, septet_length, test_decode[i].expected_septet_length); - return -1; + printf("Decode case %d: return value %d (expected %d)\n", i, nchars, strlen(result)); + + OSMO_ASSERT(strcmp(result, (const char *)test_decode[i].expected) == 0); + OSMO_ASSERT(nchars == strlen(result)); + + /* check buffer limiting */ + memset(result, 0xaa, sizeof(result)); + + for (buffer_size = 0; + buffer_size < test_encode[i].expected_septet_length + 1 + && buffer_size < sizeof(result) - 1; + ++buffer_size) + { + nchars = gsm_7bit_decode_n_hdr(result, buffer_size, test_decode[i].input, + test_decode[i].expected_septet_length, test_decode[i].ud_hdr_ind); + + OSMO_ASSERT(nchars <= buffer_size); + OSMO_ASSERT(result[buffer_size] == (char)0xaa); + if (buffer_size > 0) { + OSMO_ASSERT(result[nchars] == '\0'); + } } } diff --git a/tests/sms/sms_test.ok b/tests/sms/sms_test.ok index ce6cb17..915a59c 100644 --- a/tests/sms/sms_test.ok +++ b/tests/sms/sms_test.ok @@ -1,4 +1,14 @@ SMS testing +Encode case 0: Octet length 8 (expected 8, computed 8), septet length 9 (expected 9) +Encode case 1: Octet length 36 (expected 36, computed 36), septet length 41 (expected 41) +Encode case 2: Octet length 35 (expected 35, computed 35), septet length 39 (expected 39) +Encode case 3: Octet length 35 (expected 35, computed 35), septet length 40 (expected 40) +Decode case 0: return value 9 (expected 9) +Decode case 1: return value 40 (expected 40) +Decode case 2: return value 31 (expected 31) +Decode case 3: return value 32 (expected 32) +Decode case 4: return value 153 (expected 153) +Decode case 5: return value 40 (expected 40) Encoding some tests and printing number of septets/octets SEPTETS: 8 OCTETS: 7 Done diff --git a/tests/ussd/ussd_test.c b/tests/ussd/ussd_test.c index e3e8e08..9985ac5 100644 --- a/tests/ussd/ussd_test.c +++ b/tests/ussd/ussd_test.c @@ -73,20 +73,44 @@ static void test_7bit_ussd(const char *text, const char *encoded_hex, const char { uint8_t coded[256]; char decoded[256]; - int y; + int octets_written; + int buffer_size; + int nchars; printf("original = %s\n", osmo_hexdump((uint8_t *)text, strlen(text))); - gsm_7bit_encode_ussd(coded, text, &y); - printf("encoded = %s\n", osmo_hexdump(coded, y)); + gsm_7bit_encode_n_ussd(coded, sizeof(coded), text, &octets_written); + printf("encoded = %s\n", osmo_hexdump(coded, octets_written)); - OSMO_ASSERT(strcmp(encoded_hex, osmo_hexdump_nospc(coded, y)) == 0); + OSMO_ASSERT(strcmp(encoded_hex, osmo_hexdump_nospc(coded, octets_written)) == 0); - gsm_7bit_decode_ussd(decoded, coded, y * 8 / 7); - y = strlen(decoded); - printf("decoded = %s\n\n", osmo_hexdump((uint8_t *)decoded, y)); + gsm_7bit_decode_n_ussd(decoded, sizeof(decoded), coded, octets_written * 8 / 7); + octets_written = strlen(decoded); + printf("decoded = %s\n\n", osmo_hexdump((uint8_t *)decoded, octets_written)); OSMO_ASSERT(strncmp(text, decoded, strlen(text)) == 0); OSMO_ASSERT(strcmp(appended_after_decode, decoded + strlen(text)) == 0); + + /* check buffer limiting */ + memset(decoded, 0xaa, sizeof(decoded)); + + for (buffer_size = 0; buffer_size < sizeof(decoded) - 1; ++buffer_size) + { + nchars = gsm_7bit_decode_n_ussd(decoded, buffer_size, coded, octets_written * 8 / 7); + OSMO_ASSERT(nchars <= buffer_size); + OSMO_ASSERT(decoded[buffer_size] == (char)0xaa); + if (buffer_size > 0) { + OSMO_ASSERT(decoded[nchars] == '\0'); + } + } + + memset(coded, 0xaa, sizeof(coded)); + + for (buffer_size = 0; buffer_size < sizeof(coded) - 1; ++buffer_size) + { + gsm_7bit_encode_n_ussd(coded, buffer_size, text, &octets_written); + OSMO_ASSERT(octets_written <= buffer_size); + OSMO_ASSERT(coded[buffer_size] == 0xaa); + } } int main(int argc, char **argv) -- 1.7.9.5 From jerlbeck at sysmocom.de Mon Aug 12 12:08:18 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 12 Aug 2013 14:08:18 +0200 Subject: [PATCH 2/2] sms: Added comment about the gsm_7bit_alphabet table In-Reply-To: <1376309298-9472-1-git-send-email-jerlbeck@sysmocom.de> References: <1376309298-9472-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1376309298-9472-2-git-send-email-jerlbeck@sysmocom.de> The table structure is not intuitive, so this comment shall aid to understand this. --- src/gsm/gsm_utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index d76a5f2..5de4c4b 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -80,8 +80,12 @@ * left out as they can't be handled with a char and * since most phones don't display or write these * characters this would only needlessly make the code - * more complex -*/ + * more complex. + * + * Note that this table contains the latin1->7bit mapping _and_ has + * been merged with the reverse mapping (7bit->latin1) for the + * extended characters at offset 0x7f. + */ static unsigned char gsm_7bit_alphabet[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0a, 0xff, 0xff, 0x0d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -- 1.7.9.5 From holger at freyther.de Mon Aug 12 12:42:29 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 12 Aug 2013 14:42:29 +0200 Subject: [PATCH 1/2] sms: Added result buffer size parameter to 7bit conv funs In-Reply-To: <1376309298-9472-1-git-send-email-jerlbeck@sysmocom.de> References: <1376309298-9472-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130812124229.GC10950@xiaoyu.lan> On Mon, Aug 12, 2013 at 02:08:17PM +0200, Jacob Erlbeck wrote: > The 7bit<->8bit encoding/decoding functions didn't check whether > there is still enough space in the destination buffer. Therefore a > buffer size parameter ('n' like in snprintf) has been added to each > of the functions which leads to truncation if the the buffer is too > small. I think there has to be a comma and 'the the' > In addition, the return value of the decoding functions has been > changed to number of characters written (excluding \0), so this > value is always equal to strlen(decoded) if n>0. I commented that in the code, but maybe here as well. Maybe it is easier to forbid n==0 and add an OSMO_ASSERT? The argument for that is one can unconditionally printf the result? > +/* > + * The following functions write at most n octets to the destination buffer > + * ('decoded' or 'result') and return the number of octets written (always > + * <= n). > + */ Doxygen has the concept of groups[1], do you want to use that for these methods or do you just want to remove this comment? > msgb_put_u8(msg, ASN1_OCTET_STRING_TAG); > ussd_len_ptr = msgb_put(msg, 1); > data = msgb_put(msg, 0); > - gsm_7bit_encode_ussd(data, text, &len); > + gsm_7bit_encode_n_ussd(data, msgb_tailroom(msg), text, &len); i think there is no test coverage for all of these calls. > + gsm_7bit_decode_n_ussd(req->text, sizeof (req->text), no space. :) or just forbid this case? OSMO_ASSERT(n > 0)? This way no one can accidently do a printf on the text and crash? > - if (c == 0x1b && i + 1 < septet_l) { > + c8 = gsm_7bit_alphabet[0x7f + c7]; > + } else if (c7 == 0x1b && i + 1 < septet_l) { > next_is_ext = 1; > + continue; we try to avoid continue/break inside if statements. I have no counter proposal for the code flow though. :} > + nchars = (int)text - (int)text_buf_begin; I thought you wanted to use ptrdiff_t here? I think we should not truncate a 64bit point to potentially 32bit. > -int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets) > +int gsm_7bit_encode_n(uint8_t *result, size_t n, const char *data, int *octets) > { > int y = 0; > + int o; > + int max_septets = n * 8 / 7; > > /* prepare for the worst case, every character expanding to two bytes */ > uint8_t *rdata = calloc(strlen(data) * 2, sizeof(uint8_t)); while we are here we could add the null check. and null terminate the result? > y = gsm_septet_encode(rdata, data); > - *octets = gsm_septets2octets(result, rdata, y, 0); > + > + if (y > max_septets) > + y = max_septets; when would this happen? does this break an assumption of our code? > +int gsm_7bit_encode_n_ussd(uint8_t *result, size_t n, const char *data, int *octets) > +{ > + int y; > + > + y = gsm_7bit_encode_n(result, n, data, octets); > + /* if last octet contains only one bit, add */ > + if (((y * 7) & 7) == 1) > + result[(*octets) - 1] |= ('\r' << 1); okay, y >= 1 => *octets >= 1. But shouldn't we increase y in this case too? > + .input = (const uint8_t *)concatenated_text, i think we tend to put a ' ' after the ')'. But thanks for fixing all the warnings GCC started to emit. holger [1] http://www.stack.nl/~dimitri/doxygen/manual/grouping.html From jerlbeck at sysmocom.de Mon Aug 12 15:07:53 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 12 Aug 2013 17:07:53 +0200 Subject: [PATCH 1/2] sms: Added result buffer size parameter to 7bit conv funs In-Reply-To: <1376309298-9472-1-git-send-email-jerlbeck@sysmocom.de> References: <1376309298-9472-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1376320074-4130-1-git-send-email-jerlbeck@sysmocom.de> The 7bit<->8bit encoding/decoding functions didn't check whether there is still enough space in the destination buffer. Therefore a buffer size parameter has been added to each of the functions which is used to truncate the output if the buffer is too small. In addition, the return value of the decoding functions has been changed to number of characters written (excluding \0), so this value is always equal to strlen(decoded). The old functions are still available as wrapper functions. --- include/osmocom/gsm/gsm_utils.h | 59 ++++++++++++++-- src/gsm/gsm0480.c | 11 ++- src/gsm/gsm_utils.c | 145 +++++++++++++++++++++++++-------------- src/gsm/libosmogsm.map | 7 +- tests/sms/sms_test.c | 124 ++++++++++++++++++--------------- tests/sms/sms_test.ok | 10 +++ tests/ussd/ussd_test.c | 50 ++++++++++++-- tests/ussd/ussd_test.ok | 11 +++ 8 files changed, 290 insertions(+), 127 deletions(-) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 6cd46e4..c111f94 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -25,6 +25,7 @@ #ifndef GSM_UTILS_H #define GSM_UTILS_H +#include #include #define ADD_MODULO(sum, delta, modulo) do { \ @@ -56,17 +57,54 @@ enum gsm_band { const char *gsm_band_name(enum gsm_band band); enum gsm_band gsm_band_parse(const char *mhz); -int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length); -int gsm_7bit_decode_ussd(char *decoded, const uint8_t *user_data, uint8_t length); -int gsm_7bit_decode_hdr(char *decoded, const uint8_t *user_data, uint8_t length, uint8_t ud_hdr_ind); -int gsm_7bit_encode(uint8_t *result, const char *data); -int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets_written); -int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets_written); +/*! + * \brief Decode a sequence of GSM 03.38 encoded 7 bit characters. + * + * \param decoded The destination buffer for the decoded characters. + * \param n A maximum of n chars is written (incl. terminating \0). + * Requires n >= 1. + * \param user_data A pointer to the start of the packed 7bit character + * sequence. + * \param length The length of the input sequence (in octets). + * + * \returns the number of (8 bit) chars written excluding the terminating \0. + * This is the same like strlen(decoded). + */ +int gsm_7bit_decode_n(char *decoded, size_t n, const uint8_t *user_data, uint8_t length); + +/*! + * \brief Decode a sequence of 7 bit characters (USSD encoding). + * + * \see gsm_7bit_encode_n() + */ +int gsm_7bit_decode_n_ussd(char *decoded, size_t n, const uint8_t *user_data, uint8_t length); + +/** + * \brief Encode a text string into GSM 03.38 encoded 7 bit characters. + * + * \param result The destination buffer for the packed 7 bit sequence. + * \param n A maximum of n octets is written. + * \param data A pointer to the start of the \0 terminated 8 bit character + * string. + * \param octets_written Iff not NULL, *octets_written will be set to the + * number of octets written to the result buffer. + * + * \returns the number of septets that have been created. + */ +int gsm_7bit_encode_n(uint8_t *result, size_t n, const char *data, int *octets_written); -/* the three functions below are helper functions and here for the unit test */ +/*! + * \brief Encode a text string into GSM 03.38 encoded 7 bit characters (USSD encoding). + * + * \see gsm_7bit_decode_n() + */ +int gsm_7bit_encode_n_ussd(uint8_t *result, size_t n, const char *data, int *octets_written); + +/* the four functions below are helper functions and here for the unit test */ int gsm_septets2octets(uint8_t *result, const uint8_t *rdata, uint8_t septet_len, uint8_t padding); int gsm_septet_encode(uint8_t *result, const char *data); uint8_t gsm_get_octet_len(const uint8_t sept_len); +int gsm_7bit_decode_n_hdr(char *decoded, size_t n, const uint8_t *user_data, uint8_t length, uint8_t ud_hdr_ind); unsigned int ms_class_gmsk_dbm(enum gsm_band band, int ms_class); @@ -154,5 +192,12 @@ enum gsm_chan_t { _GSM_LCHAN_MAX }; +/* Deprectated functions */ +int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length) __attribute__((deprecated ("Use gsm_7bit_decode_n() instead"))); +int gsm_7bit_decode_ussd(char *decoded, const uint8_t *user_data, uint8_t length) __attribute__((deprecated ("Use gsm_7bit_decode_n_ussd() instead"))); +int gsm_7bit_encode(uint8_t *result, const char *data) __attribute__((deprecated ("Use gsm_7bit_encode_n() instead"))); +int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets_written) __attribute__((deprecated ("Use gsm_7bit_encode_n_ussd() instead"))); +int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets_written) __attribute__((deprecated ("Use gsm_7bit_encode_n() instead"))); + #endif diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c index cc693fe..92a62dc 100644 --- a/src/gsm/gsm0480.c +++ b/src/gsm/gsm0480.c @@ -105,7 +105,7 @@ struct msgb *gsm0480_create_unstructuredSS_Notify(int alertPattern, const char * msgb_put_u8(msg, ASN1_OCTET_STRING_TAG); ussd_len_ptr = msgb_put(msg, 1); data = msgb_put(msg, 0); - gsm_7bit_encode_ussd(data, text, &len); + gsm_7bit_encode_n_ussd(data, msgb_tailroom(msg), text, &len); msgb_put(msg, len); ussd_len_ptr[0] = len; /* USSD-String } */ @@ -172,7 +172,7 @@ struct msgb *gsm0480_create_notifySS(const char *text) msgb_put_u8(msg, 0x82); tmp_len = msgb_put(msg, 1); data = msgb_put(msg, 0); - gsm_7bit_encode_ussd(data, text, &len); + gsm_7bit_encode_n_ussd(data, msgb_tailroom(msg), text, &len); tmp_len[0] = len; msgb_put(msg, len); @@ -398,10 +398,7 @@ static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length, if ((dcs == 0x0F) && (uss_req_data[5] == ASN1_OCTET_STRING_TAG)) { num_chars = (uss_req_data[6] * 8) / 7; - /* Prevent a mobile-originated buffer-overrun! */ - if (num_chars > MAX_LEN_USSD_STRING) - num_chars = MAX_LEN_USSD_STRING; - gsm_7bit_decode_ussd(req->text, + gsm_7bit_decode_n_ussd(req->text, sizeof(req->text), &(uss_req_data[7]), num_chars); rc = 1; } @@ -423,7 +420,7 @@ struct msgb *gsm0480_create_ussd_resp(uint8_t invoke_id, uint8_t trans_id, const /* First put the payload text into the message */ ptr8 = msgb_put(msg, 0); - gsm_7bit_encode_ussd(ptr8, text, &response_len); + gsm_7bit_encode_n_ussd(ptr8, msgb_tailroom(msg), text, &response_len); msgb_put(msg, response_len); /* Then wrap it as an Octet String */ diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index 3dd1537..e248078 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -28,7 +28,7 @@ * This library is a collection of common code used in various * GSM related sub-projects inside the Osmocom family of projects. It * includes A5/1 and A5/2 ciphers, COMP128v1, a LAPDm implementation, - * a GSM TLV parser, SMS utility routines as well as + * a GSM TLV parser, SMS utility routines as well as * protocol definitions for a series of protocols: * * Um L2 (04.06) * * Um L3 (04.08) @@ -123,12 +123,17 @@ uint8_t gsm_get_octet_len(const uint8_t sept_len){ } /* GSM 03.38 6.2.1 Character unpacking */ -int gsm_7bit_decode_hdr(char *text, const uint8_t *user_data, uint8_t septet_l, uint8_t ud_hdr_ind) +int gsm_7bit_decode_n_hdr(char *text, size_t n, const uint8_t *user_data, uint8_t septet_l, uint8_t ud_hdr_ind) { int i = 0; int shift = 0; - uint8_t c; + uint8_t c7, c8; uint8_t next_is_ext = 0; + const char *text_buf_begin = text; + const char *text_buf_end = text + n; + int nchars; + + OSMO_ASSERT (n > 0); /* skip the user data header */ if (ud_hdr_ind) { @@ -139,50 +144,49 @@ int gsm_7bit_decode_hdr(char *text, const uint8_t *user_data, uint8_t septet_l, septet_l = septet_l - shift; } - for (i = 0; i < septet_l; i++) { - c = + for (i = 0; i < septet_l && text != text_buf_end - 1; i++) { + c7 = ((user_data[((i + shift) * 7 + 7) >> 3] << (7 - (((i + shift) * 7 + 7) & 7))) | (user_data[((i + shift) * 7) >> 3] >> (((i + shift) * 7) & 7))) & 0x7f; - /* this is an extension character */ if (next_is_ext) { + /* this is an extension character */ next_is_ext = 0; - *(text++) = gsm_7bit_alphabet[0x7f + c]; - continue; - } - - if (c == 0x1b && i + 1 < septet_l) { + c8 = gsm_7bit_alphabet[0x7f + c7]; + } else if (c7 == 0x1b && i + 1 < septet_l) { next_is_ext = 1; + continue; } else { - *(text++) = gsm_septet_lookup(c); + c8 = gsm_septet_lookup(c7); } + + *(text++) = c8; } - if (ud_hdr_ind) - i += shift; + nchars = text - text_buf_begin; + *text = '\0'; - return i; + return nchars; } -int gsm_7bit_decode(char *text, const uint8_t *user_data, uint8_t septet_l) +int gsm_7bit_decode_n(char *text, size_t n, const uint8_t *user_data, uint8_t septet_l) { - return gsm_7bit_decode_hdr(text, user_data, septet_l, 0); + return gsm_7bit_decode_n_hdr(text, n, user_data, septet_l, 0); } -int gsm_7bit_decode_ussd(char *text, const uint8_t *user_data, uint8_t length) +int gsm_7bit_decode_n_ussd(char *text, size_t n, const uint8_t *user_data, uint8_t length) { - int i; + int nchars; - gsm_7bit_decode_hdr(text, user_data, length, 0); - i = strlen(text); + nchars = gsm_7bit_decode_n_hdr(text, n, user_data, length, 0); /* remove last , if it fits up to the end of last octet */ - if (i && (user_data[gsm_get_octet_len(length) - 1] >> 1) == '\r') - text[--i] = '\0'; + if (nchars && (user_data[gsm_get_octet_len(length) - 1] >> 1) == '\r') + text[--nchars] = '\0'; - return i; + return nchars; } /* GSM 03.38 6.2.1 Prepare character packing */ @@ -261,38 +265,28 @@ int gsm_septets2octets(uint8_t *result, const uint8_t *rdata, uint8_t septet_len } /* GSM 03.38 6.2.1 Character packing */ -int gsm_7bit_encode(uint8_t *result, const char *data) -{ - int out; - return gsm_7bit_encode_oct(result, data, &out); -} - -int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets) -{ - int y; - - y = gsm_7bit_encode_oct(result, data, octets); - /* if last octet contains only one bit, add */ - if (((y * 7) & 7) == 1) - result[(*octets) - 1] |= ('\r' << 1); - /* if last character is and completely fills last octet, add - * another . */ - if (y && ((y * 7) & 7) == 0 && (result[(*octets) - 1] >> 1) == '\r') { - result[(*octets)++] = '\r'; - y++; - } - - return y; -} - -int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets) +int gsm_7bit_encode_n(uint8_t *result, size_t n, const char *data, int *octets) { int y = 0; + int o; + int max_septets = n * 8 / 7; /* prepare for the worst case, every character expanding to two bytes */ uint8_t *rdata = calloc(strlen(data) * 2, sizeof(uint8_t)); y = gsm_septet_encode(rdata, data); - *octets = gsm_septets2octets(result, rdata, y, 0); + + if (y > max_septets) { + /* + * Limit the number of septets to avoid the generation + * of more than n octets. + */ + y = max_septets; + } + + o = gsm_septets2octets(result, rdata, y, 0); + + if (octets) + *octets = o; free(rdata); @@ -309,6 +303,24 @@ int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets) return y; } +int gsm_7bit_encode_n_ussd(uint8_t *result, size_t n, const char *data, int *octets) +{ + int y; + + y = gsm_7bit_encode_n(result, n, data, octets); + /* if last octet contains only one bit, add */ + if (((y * 7) & 7) == 1) + result[(*octets) - 1] |= ('\r' << 1); + /* if last character is and completely fills last octet, add + * another . */ + if (y && ((y * 7) & 7) == 0 && (result[(*octets) - 1] >> 1) == '\r' && *octets < n - 1) { + result[(*octets)++] = '\r'; + y++; + } + + return y; +} + /* convert power class to dBm according to GSM TS 05.05 */ unsigned int ms_class_gmsk_dbm(enum gsm_band band, int class) { @@ -373,7 +385,7 @@ int ms_pwr_ctl_lvl(enum gsm_band band, unsigned int dbm) case GSM_BAND_1800: if (dbm >= 36) return 29; - else if (dbm >= 34) + else if (dbm >= 34) return 30; else if (dbm >= 32) return 31; @@ -662,3 +674,34 @@ uint32_t gprs_tmsi2tlli(uint32_t p_tmsi, enum gprs_tlli_type type) } return tlli; } + +/* Wrappers for deprecated functions: */ + +int gsm_7bit_decode(char *text, const uint8_t *user_data, uint8_t septet_l) +{ + gsm_7bit_decode_n(text, SIZE_MAX, user_data, septet_l); + + /* Mimic the original behaviour. */ + return septet_l; +} + +int gsm_7bit_decode_ussd(char *text, const uint8_t *user_data, uint8_t length) +{ + return gsm_7bit_decode_n_ussd(text, SIZE_MAX, user_data, length); +} + +int gsm_7bit_encode(uint8_t *result, const char *data) +{ + int out; + return gsm_7bit_encode_n(result, SIZE_MAX, data, &out); +} + +int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets) +{ + return gsm_7bit_encode_n_ussd(result, SIZE_MAX, data, octets); +} + +int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets) +{ + return gsm_7bit_encode_n(result, SIZE_MAX, data, octets); +} diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 1b985e1..9d15d66 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -133,11 +133,16 @@ gsm48_rr_att_tlvdef; gsm_7bit_decode; gsm_7bit_decode_ussd; -gsm_7bit_decode_hdr; gsm_7bit_encode; gsm_7bit_encode_ussd; gsm_7bit_encode_oct; +gsm_7bit_decode_n; +gsm_7bit_decode_n_ussd; +gsm_7bit_decode_n_hdr; +gsm_7bit_encode_n; +gsm_7bit_encode_n_ussd; + gsm_arfcn2band; gsm_arfcn2freq10; gsm_freq102arfcn; diff --git a/tests/sms/sms_test.c b/tests/sms/sms_test.c index e48f9a3..3188a18 100644 --- a/tests/sms/sms_test.c +++ b/tests/sms/sms_test.c @@ -116,14 +116,14 @@ static const uint8_t concatenated_part2_enc[] = { static const struct test_case test_multiple_encode[] = { { - .input = concatenated_text, + .input = (const uint8_t *) concatenated_text, .expected = concatenated_part1_enc, .expected_octet_length = sizeof(concatenated_part1_enc), .expected_septet_length = concatenated_part1_septet_length, .ud_hdr_ind = 1, }, { - .input = concatenated_text, + .input = (const uint8_t *) concatenated_text, .expected = concatenated_part2_enc, .expected_octet_length = sizeof(concatenated_part2_enc), .expected_septet_length = concatenated_part2_septet_length, @@ -134,28 +134,28 @@ static const struct test_case test_multiple_encode[] = static const struct test_case test_encode[] = { { - .input = simple_text, + .input = (const uint8_t *) simple_text, .expected = simple_enc, .expected_octet_length = sizeof(simple_enc), .expected_septet_length = simple_septet_length, .ud_hdr_ind = 0, }, { - .input = escape_text, + .input = (const uint8_t *) escape_text, .expected = escape_enc, .expected_octet_length = sizeof(escape_enc), .expected_septet_length = escape_septet_length, .ud_hdr_ind = 0, }, { - .input = enhanced_text, + .input = (const uint8_t *) enhanced_text, .expected = enhanced_enc, .expected_octet_length = sizeof(enhanced_enc), .expected_septet_length = enhanced_septet_length, .ud_hdr_ind = 0, }, { - .input = enhancedV2_text, + .input = (const uint8_t *) enhancedV2_text, .expected = enhancedV2_enc, .expected_octet_length = sizeof(enhancedV2_enc), .expected_septet_length = enhancedV2_septet_length, @@ -168,42 +168,42 @@ static const struct test_case test_decode[] = { .input = simple_enc, .input_length = sizeof(simple_enc), - .expected = simple_text, + .expected = (const uint8_t *) simple_text, .expected_septet_length = simple_septet_length, .ud_hdr_ind = 0, }, { .input = escape_enc, .input_length = sizeof(escape_enc), - .expected = escape_text, + .expected = (const uint8_t *) escape_text, .expected_septet_length = escape_septet_length, .ud_hdr_ind = 0, }, { .input = enhanced_enc, .input_length = sizeof(enhanced_enc), - .expected = enhanced_text, + .expected = (const uint8_t *) enhanced_text, .expected_septet_length = enhanced_septet_length, .ud_hdr_ind = 0, }, { .input = enhancedV2_enc, .input_length = sizeof(enhancedV2_enc), - .expected = enhancedV2_text, + .expected = (const uint8_t *) enhancedV2_text, .expected_septet_length = enhancedV2_septet_length, .ud_hdr_ind = 0, }, { .input = concatenated_part1_enc, .input_length = sizeof(concatenated_part1_enc), - .expected = splitted_text_part1, + .expected = (const uint8_t *) splitted_text_part1, .expected_septet_length = concatenated_part1_septet_length_with_header, .ud_hdr_ind = 1, }, { .input = concatenated_part2_enc, .input_length = sizeof(concatenated_part2_enc), - .expected = splitted_text_part2, + .expected = (const uint8_t *) splitted_text_part2, .expected_septet_length = concatenated_part2_septet_length_with_header, .ud_hdr_ind = 1, }, @@ -216,7 +216,7 @@ static void test_octet_return() printf("Encoding some tests and printing number of septets/octets\n"); - septets = gsm_7bit_encode_oct((uint8_t *) out, "test1234", &oct); + septets = gsm_7bit_encode_n((uint8_t *) out, sizeof(out), "test1234", &oct); printf("SEPTETS: %d OCTETS: %d\n", septets, oct); printf("Done\n"); @@ -227,43 +227,58 @@ int main(int argc, char** argv) printf("SMS testing\n"); struct msgb *msg; uint8_t i; - + uint16_t buffer_size; uint8_t octet_length; + int octets_written; + uint8_t computed_octet_length; uint8_t septet_length; uint8_t gsm_septet_length; uint8_t coded[256]; uint8_t tmp[160]; uint8_t septet_data[256]; uint8_t ud_header[6]; + int nchars; char result[256]; /* test 7-bit encoding */ for (i = 0; i < ARRAY_SIZE(test_encode); ++i) { memset(coded, 0x42, sizeof(coded)); - septet_length = gsm_7bit_encode(coded, test_encode[i].input); - octet_length = gsm_get_octet_len(septet_length); - if (octet_length != test_encode[i].expected_octet_length) { - fprintf(stderr, "Encode case %d: Octet length failure. Got %d, expected %d\n", - i, octet_length, test_encode[i].expected_octet_length); - return -1; - } - - if (septet_length != test_encode[i].expected_septet_length){ - fprintf(stderr, "Encode case %d: Septet length failure. Got %d, expected %d\n", - i, septet_length, test_encode[i].expected_septet_length); - return -1; - } - - if (memcmp(coded, test_encode[i].expected, octet_length) != 0) { - fprintf(stderr, "Encoded content does not match for case %d\n", - i); - return -1; + septet_length = gsm_7bit_encode_n(coded, sizeof(coded), + (const char *) test_encode[i].input, + &octets_written); + computed_octet_length = gsm_get_octet_len(septet_length); + printf("Encode case %d: " + "Octet length %d (expected %d, computed %d), " + "septet length %d (expected %d)\n" + , i + , octets_written, test_encode[i].expected_octet_length, computed_octet_length + , septet_length, test_encode[i].expected_septet_length + ); + + OSMO_ASSERT (octets_written == test_encode[i].expected_octet_length); + OSMO_ASSERT (octets_written == computed_octet_length); + OSMO_ASSERT (memcmp(coded, test_encode[i].expected, octets_written) == 0); + + /* check buffer limiting */ + memset(coded, 0xaa, sizeof(coded)); + + for (buffer_size = 0; + buffer_size < test_encode[i].expected_octet_length + 1 + && buffer_size < sizeof(coded) - 1; + ++buffer_size) + { + gsm_7bit_encode_n(coded, buffer_size, + (const char *) test_encode[i].input, + &octets_written); + + OSMO_ASSERT(octets_written <= buffer_size); + OSMO_ASSERT(coded[buffer_size] == 0xaa); } } /* Test: encode multiple SMS */ - int number_of_septets = gsm_septet_encode(septet_data, test_multiple_encode[0].input); + int number_of_septets = gsm_septet_encode(septet_data, (const char *) test_multiple_encode[0].input); /* SMS part 1 */ memset(tmp, 0x42, sizeof(tmp)); @@ -281,11 +296,7 @@ int main(int argc, char** argv) memset(coded, 0x42, sizeof(coded)); memcpy(coded, tmp, octet_length + 6); - if (memcmp(coded, test_multiple_encode[0].expected, octet_length) != 0) { - fprintf(stderr, "Multiple-SMS encoded content does not match for part 1\n"); - return -1; - } - + OSMO_ASSERT(memcmp(coded, test_multiple_encode[0].expected, octet_length) == 0); /* SMS part 2 */ memset(tmp, 0x42, sizeof(tmp)); @@ -303,27 +314,32 @@ int main(int argc, char** argv) memset(coded, 0x42, sizeof(coded)); memcpy(coded, tmp, octet_length + 6); - if (memcmp(coded, test_multiple_encode[1].expected, octet_length) != 0) { - fprintf(stderr, "Multiple-SMS encoded content does not match for part 2\n"); - return -1; - } - - + OSMO_ASSERT(memcmp(coded, test_multiple_encode[1].expected, octet_length) == 0); /* test 7-bit decoding */ for (i = 0; i < ARRAY_SIZE(test_decode); ++i) { - memset(result, 0x42, sizeof(coded)); - septet_length = gsm_7bit_decode_hdr(result, test_decode[i].input, + memset(result, 0x42, sizeof(result)); + nchars = gsm_7bit_decode_n_hdr(result, sizeof(result), test_decode[i].input, test_decode[i].expected_septet_length, test_decode[i].ud_hdr_ind); + printf("Decode case %d: return value %d (expected %d)\n", i, nchars, strlen(result)); - if (strcmp(result, test_decode[i].expected) != 0) { - fprintf(stderr, "Test case %d failed to decode.\n", i); - return -1; - } - if (septet_length != test_decode[i].expected_septet_length) { - fprintf(stderr, "Decode case %d: Septet length failure. Got %d, expected %d\n", - i, septet_length, test_decode[i].expected_septet_length); - return -1; + OSMO_ASSERT(strcmp(result, (const char *) test_decode[i].expected) == 0); + OSMO_ASSERT(nchars == strlen(result)); + + /* check buffer limiting */ + memset(result, 0xaa, sizeof(result)); + + for (buffer_size = 1; + buffer_size < test_encode[i].expected_septet_length + 1 + && buffer_size < sizeof(result) - 1; + ++buffer_size) + { + nchars = gsm_7bit_decode_n_hdr(result, buffer_size, test_decode[i].input, + test_decode[i].expected_septet_length, test_decode[i].ud_hdr_ind); + + OSMO_ASSERT(nchars <= buffer_size); + OSMO_ASSERT(result[buffer_size] == (char)0xaa); + OSMO_ASSERT(result[nchars] == '\0'); } } diff --git a/tests/sms/sms_test.ok b/tests/sms/sms_test.ok index ce6cb17..915a59c 100644 --- a/tests/sms/sms_test.ok +++ b/tests/sms/sms_test.ok @@ -1,4 +1,14 @@ SMS testing +Encode case 0: Octet length 8 (expected 8, computed 8), septet length 9 (expected 9) +Encode case 1: Octet length 36 (expected 36, computed 36), septet length 41 (expected 41) +Encode case 2: Octet length 35 (expected 35, computed 35), septet length 39 (expected 39) +Encode case 3: Octet length 35 (expected 35, computed 35), septet length 40 (expected 40) +Decode case 0: return value 9 (expected 9) +Decode case 1: return value 40 (expected 40) +Decode case 2: return value 31 (expected 31) +Decode case 3: return value 32 (expected 32) +Decode case 4: return value 153 (expected 153) +Decode case 5: return value 40 (expected 40) Encoding some tests and printing number of septets/octets SEPTETS: 8 OCTETS: 7 Done diff --git a/tests/ussd/ussd_test.c b/tests/ussd/ussd_test.c index e3e8e08..b04f8e8 100644 --- a/tests/ussd/ussd_test.c +++ b/tests/ussd/ussd_test.c @@ -73,20 +73,42 @@ static void test_7bit_ussd(const char *text, const char *encoded_hex, const char { uint8_t coded[256]; char decoded[256]; - int y; + int octets_written; + int buffer_size; + int nchars; printf("original = %s\n", osmo_hexdump((uint8_t *)text, strlen(text))); - gsm_7bit_encode_ussd(coded, text, &y); - printf("encoded = %s\n", osmo_hexdump(coded, y)); + gsm_7bit_encode_n_ussd(coded, sizeof(coded), text, &octets_written); + printf("encoded = %s\n", osmo_hexdump(coded, octets_written)); - OSMO_ASSERT(strcmp(encoded_hex, osmo_hexdump_nospc(coded, y)) == 0); + OSMO_ASSERT(strcmp(encoded_hex, osmo_hexdump_nospc(coded, octets_written)) == 0); - gsm_7bit_decode_ussd(decoded, coded, y * 8 / 7); - y = strlen(decoded); - printf("decoded = %s\n\n", osmo_hexdump((uint8_t *)decoded, y)); + gsm_7bit_decode_n_ussd(decoded, sizeof(decoded), coded, octets_written * 8 / 7); + octets_written = strlen(decoded); + printf("decoded = %s\n\n", osmo_hexdump((uint8_t *)decoded, octets_written)); OSMO_ASSERT(strncmp(text, decoded, strlen(text)) == 0); OSMO_ASSERT(strcmp(appended_after_decode, decoded + strlen(text)) == 0); + + /* check buffer limiting */ + memset(decoded, 0xaa, sizeof(decoded)); + + for (buffer_size = 1; buffer_size < sizeof(decoded) - 1; ++buffer_size) + { + nchars = gsm_7bit_decode_n_ussd(decoded, buffer_size, coded, octets_written * 8 / 7); + OSMO_ASSERT(nchars <= buffer_size); + OSMO_ASSERT(decoded[buffer_size] == (char)0xaa); + OSMO_ASSERT(decoded[nchars] == '\0'); + } + + memset(coded, 0xaa, sizeof(coded)); + + for (buffer_size = 0; buffer_size < sizeof(coded) - 1; ++buffer_size) + { + gsm_7bit_encode_n_ussd(coded, buffer_size, text, &octets_written); + OSMO_ASSERT(octets_written <= buffer_size); + OSMO_ASSERT(coded[buffer_size] == 0xaa); + } } int main(int argc, char **argv) @@ -94,6 +116,7 @@ int main(int argc, char **argv) struct ussd_request req; const int size = sizeof(ussd_request); int i; + struct msgb *msg; osmo_init_logging(&info); @@ -122,5 +145,18 @@ int main(int argc, char **argv) test_7bit_ussd("0123456\r", "b0986c46abd91a0d", "\r"); test_7bit_ussd("012345\r", "b0986c46ab351a", ""); + printf("Checking GSM 04.80 USSD message generation.\n"); + + test_7bit_ussd("", "", ""); + msg = gsm0480_create_unstructuredSS_Notify (0x00, ""); + printf ("Created unstructuredSS_Notify (0x00): %s\n", + osmo_hexdump(msgb_data(msg), msgb_length(msg))); + msgb_free (msg); + + test_7bit_ussd("forty-two", "e6b79c9e6fd1ef6f", ""); + msg = gsm0480_create_unstructuredSS_Notify (0x42, "forty-two"); + printf ("Created unstructuredSS_Notify (0x42): %s\n", + osmo_hexdump(msgb_data(msg), msgb_length(msg))); + msgb_free (msg); return 0; } diff --git a/tests/ussd/ussd_test.ok b/tests/ussd/ussd_test.ok index 91f2a31..54d59ee 100644 --- a/tests/ussd/ussd_test.ok +++ b/tests/ussd/ussd_test.ok @@ -72,3 +72,14 @@ original = 30 31 32 33 34 35 0d encoded = b0 98 6c 46 ab 35 1a decoded = 30 31 32 33 34 35 0d +Checking GSM 04.80 USSD message generation. +original = +encoded = +decoded = + +Created unstructuredSS_Notify (0x00): 30 08 04 01 0f 04 00 04 01 00 +original = 66 6f 72 74 79 2d 74 77 6f +encoded = e6 b7 9c 9e 6f d1 ef 6f +decoded = 66 6f 72 74 79 2d 74 77 6f + +Created unstructuredSS_Notify (0x42): 30 10 04 01 0f 04 08 e6 b7 9c 9e 6f d1 ef 6f 04 01 42 -- 1.7.9.5 From jerlbeck at sysmocom.de Mon Aug 12 15:07:54 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 12 Aug 2013 17:07:54 +0200 Subject: [PATCH 2/2] sms: Added comment about the gsm_7bit_alphabet table In-Reply-To: <1376320074-4130-1-git-send-email-jerlbeck@sysmocom.de> References: <1376309298-9472-1-git-send-email-jerlbeck@sysmocom.de> <1376320074-4130-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1376320074-4130-2-git-send-email-jerlbeck@sysmocom.de> The table structure is not intuitive, so this comment shall aid to understand this. --- src/gsm/gsm_utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index e248078..5241c91 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -80,8 +80,12 @@ * left out as they can't be handled with a char and * since most phones don't display or write these * characters this would only needlessly make the code - * more complex -*/ + * more complex. + * + * Note that this table contains the latin1->7bit mapping _and_ has + * been merged with the reverse mapping (7bit->latin1) for the + * extended characters at offset 0x7f. + */ static unsigned char gsm_7bit_alphabet[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0a, 0xff, 0xff, 0x0d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -- 1.7.9.5 From jerlbeck at sysmocom.de Mon Aug 12 15:13:19 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 12 Aug 2013 17:13:19 +0200 Subject: [PATCH] tests: Move expensive tests to the end of the list Message-ID: <1376320399-4182-1-git-send-email-jerlbeck@sysmocom.de> This lets make check fail earlier (in average) to shorten the debugging cycle time. --- tests/testsuite.at | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/testsuite.at b/tests/testsuite.at index 1a6fa55..97d0adc 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -9,13 +9,6 @@ cat $abs_srcdir/a5/a5_test.ok > expout AT_CHECK([$abs_top_builddir/tests/a5/a5_test], [0], [expout]) AT_CLEANUP -AT_SETUP([bssgp-fc]) -AT_KEYWORDS([bssgp-fc]) -cat $abs_srcdir/gb/bssgp_fc_tests.ok > expout -cat $abs_srcdir/gb/bssgp_fc_tests.err > experr -AT_CHECK([$abs_top_srcdir/tests/gb/bssgp_fc_tests.sh $abs_top_builddir/tests/gb], [0], [expout], [experr]) -AT_CLEANUP - AT_SETUP([bits]) AT_KEYWORDS([bits]) cat $abs_srcdir/bits/bitrev_test.ok > expout @@ -49,12 +42,6 @@ cat $abs_srcdir/smscb/smscb_test.ok > expout AT_CHECK([$abs_top_builddir/tests/smscb/smscb_test], [0], [expout]) AT_CLEANUP -AT_SETUP([timer]) -AT_KEYWORDS([timer]) -cat $abs_srcdir/timer/timer_test.ok > expout -AT_CHECK([$abs_top_builddir/tests/timer/timer_test -s 5], [0], [expout], [ignore]) -AT_CLEANUP - AT_SETUP([ussd]) AT_KEYWORDS([ussd]) cat $abs_srcdir/ussd/ussd_test.ok > expout @@ -118,3 +105,16 @@ AT_KEYWORDS([vty]) cat $abs_srcdir/vty/vty_test.ok > expout AT_CHECK([$abs_top_builddir/tests/vty/vty_test], [0], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([bssgp-fc]) +AT_KEYWORDS([bssgp-fc]) +cat $abs_srcdir/gb/bssgp_fc_tests.ok > expout +cat $abs_srcdir/gb/bssgp_fc_tests.err > experr +AT_CHECK([$abs_top_srcdir/tests/gb/bssgp_fc_tests.sh $abs_top_builddir/tests/gb], [0], [expout], [experr]) +AT_CLEANUP + +AT_SETUP([timer]) +AT_KEYWORDS([timer]) +cat $abs_srcdir/timer/timer_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/timer/timer_test -s 5], [0], [expout], [ignore]) +AT_CLEANUP -- 1.7.9.5 From holger at freyther.de Tue Aug 13 05:20:43 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 13 Aug 2013 07:20:43 +0200 Subject: [PATCH] tests: Move expensive tests to the end of the list In-Reply-To: <1376320399-4182-1-git-send-email-jerlbeck@sysmocom.de> References: <1376320399-4182-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130813052043.GB10011@xiaoyu.lan> On Mon, Aug 12, 2013 at 05:13:19PM +0200, Jacob Erlbeck wrote: > This lets make check fail earlier (in average) to shorten the > debugging cycle time. great idea! holger From jerlbeck at sysmocom.de Mon Aug 12 16:31:59 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Mon, 12 Aug 2013 18:31:59 +0200 Subject: [PATCH] sms: Disable deprecated message Message-ID: <1376325119-14235-1-git-send-email-jerlbeck@sysmocom.de> This is a workaround to make the freeBSD target work again. --- include/osmocom/gsm/gsm_utils.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index c111f94..1c55dfb 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -28,6 +28,8 @@ #include #include +#include + #define ADD_MODULO(sum, delta, modulo) do { \ if ((sum += delta) >= modulo) \ sum -= modulo; \ @@ -35,6 +37,18 @@ #define GSM_MAX_FN (26*51*2048) +/*! \brief Set the deprecated attribute with a message. + * + * \todo Move this to a global header utility file. + * \todo Check for compiler version to selectivly enable the message. + */ +#if 0 +#define OSMO_DEPRECATED(text) __attribute__((deprecated(text))) +#else +#define OSMO_DEPRECATED(text) __attribute__((__deprecated__)) +#endif + + struct gsm_time { uint32_t fn; /* FN count */ uint16_t t1; /* FN div (26*51) */ @@ -79,7 +93,7 @@ int gsm_7bit_decode_n(char *decoded, size_t n, const uint8_t *user_data, uint8_t */ int gsm_7bit_decode_n_ussd(char *decoded, size_t n, const uint8_t *user_data, uint8_t length); -/** +/*! * \brief Encode a text string into GSM 03.38 encoded 7 bit characters. * * \param result The destination buffer for the packed 7 bit sequence. @@ -193,11 +207,11 @@ enum gsm_chan_t { }; /* Deprectated functions */ -int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length) __attribute__((deprecated ("Use gsm_7bit_decode_n() instead"))); -int gsm_7bit_decode_ussd(char *decoded, const uint8_t *user_data, uint8_t length) __attribute__((deprecated ("Use gsm_7bit_decode_n_ussd() instead"))); -int gsm_7bit_encode(uint8_t *result, const char *data) __attribute__((deprecated ("Use gsm_7bit_encode_n() instead"))); -int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets_written) __attribute__((deprecated ("Use gsm_7bit_encode_n_ussd() instead"))); -int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets_written) __attribute__((deprecated ("Use gsm_7bit_encode_n() instead"))); +int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length) OSMO_DEPRECATED("Use gsm_7bit_decode_n() instead"); +int gsm_7bit_decode_ussd(char *decoded, const uint8_t *user_data, uint8_t length) OSMO_DEPRECATED("Use gsm_7bit_decode_n_ussd() instead"); +int gsm_7bit_encode(uint8_t *result, const char *data) OSMO_DEPRECATED("Use gsm_7bit_encode_n() instead"); +int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets_written) OSMO_DEPRECATED("Use gsm_7bit_encode_n_ussd() instead"); +int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets_written) OSMO_DEPRECATED("Use gsm_7bit_encode_n() instead"); #endif -- 1.7.9.5 From holger at freyther.de Tue Aug 13 05:19:56 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 13 Aug 2013 07:19:56 +0200 Subject: [PATCH] sms: Disable deprecated message In-Reply-To: <1376325119-14235-1-git-send-email-jerlbeck@sysmocom.de> References: <1376325119-14235-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130813051956.GA10011@xiaoyu.lan> On Mon, Aug 12, 2013 at 06:31:59PM +0200, Jacob Erlbeck wrote: > --- a/include/osmocom/gsm/gsm_utils.h > +++ b/include/osmocom/gsm/gsm_utils.h > @@ -28,6 +28,8 @@ > #include > #include > > +#include the pragma once/ifndef/define is saving us here. We will fix this properly today. From jerlbeck at sysmocom.de Tue Aug 13 08:02:55 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Tue, 13 Aug 2013 10:02:55 +0200 Subject: [PATCH] sms: Disable deprecated message In-Reply-To: <20130813051956.GA10011@xiaoyu.lan> References: <1376325119-14235-1-git-send-email-jerlbeck@sysmocom.de> <20130813051956.GA10011@xiaoyu.lan> Message-ID: <5209E82F.1090700@sysmocom.de> On 08/13/2013 07:19 AM, Holger Hans Peter Freyther wrote: > On Mon, Aug 12, 2013 at 06:31:59PM +0200, Jacob Erlbeck wrote: > >> --- a/include/osmocom/gsm/gsm_utils.h >> +++ b/include/osmocom/gsm/gsm_utils.h >> @@ -28,6 +28,8 @@ >> #include >> #include >> >> +#include > the pragma once/ifndef/define is saving us here. We will fix this properly > today. > Oops, this should have become osmocom/core/utils.h but then I decided to leave the macro definition in gsm_utils.h. I wasn't very happy with including core/utils.h in a header file just to get some macro definitions. I'd rather have a header file meant to be included by other header files that just includes some macro definitions and/or types and no function prototypes or variables. Jacob From dmi3sol at gmail.com Wed Aug 14 08:51:52 2013 From: dmi3sol at gmail.com (Dmitri Soloviev) Date: Wed, 14 Aug 2013 12:51:52 +0400 Subject: No subject Message-ID: Hi I'm still trying to run OpenBSC against a legacy MSC. All is fine, except rtp/mgcp stuff. All other procedures are performed well. Call set up is done properly, both BSSAP and MGCP. At downlink direction, GSM-FR coded messages are reaching endpoints at BSC side, and that's all: no RTP traffic between BSC and BTS. And I also found no control traffic in between osmo-bsc_mgcp and osmo-bsc or BTS Could you please give me a key. I would appreciate your help, and would be glad to write a wiki afterwards. osmo-bsc is configured with --enable-osmo-bsc the only trick here I had to do - to allow GSM FR (version 1) manually, there is a temporary patch to osmo-bsc: could not configure it from a file. Btw, what is the reason to keep such sort of knowledge at BSC side, and what is the proper way to define permitted codecs? osmo-bsc_mgcp is running, answers MGCP commands, allocates endpoints etc. MGCP call setup is done properly, MGCP allocates endpoints at BSC side (at server), but there is no RTP traffic in between BSC and BTS. Thank you, Dmitri rtp path is as follows, all MGCP formalities are met (card) 192.168.50.10:4036 <--G.711--> 172.44.3.2:4036--(transcoding)-- 192.168.1.11:5036 <--GSM FR --> 192.168.1.11:16036 (osmo-bsc_mgcp) where (card) is A-nterface GW, (transcoding) is my software I'm getting an error <000b> mgcp_network.c:348 Endpoint 0x13 data from wrong address 192.168.1.11 vs. 0.0.0.0 CallAgent is at 192.168.50.10, interfaced over OpenVPN tunnel (172.44.2.XX) So, server has two interfaces: 192.168.1.11 and 172.44.3.2 (OpenVPN) BTS is 192.168.1.4 So, mgcp is bind to 0.0.0.0, cause MGCP is controlled over VPN interface mgcp.cfg is bind ip 0.0.0.0 bind port 2427 bind early 1 rtp base 4000 sdp audio payload number 3 sdp audio payload name GSM/8000 number endpoints 31 loop 1 osmo-bsc.fcg is e1_input e1_line 0 driver ipa network network country code 250 mobile network code 07 short name OsmoBSC long name OsmoBSC auth policy closed location updating reject cause 13 ! encryption a5 1 neci 1 paging any use tch 0 rrlp mode none mm info 1 handover 0 handover window rxlev averaging 10 handover window rxqual averaging 1 handover window rxlev neighbor averaging 10 handover power budget interval 6 handover power budget hysteresis 3 handover maximum distance 9999 timer t3101 10 timer t3103 0 timer t3105 0 timer t3107 0 timer t3109 0 timer t3111 0 timer t3113 60 timer t3115 0 timer t3117 0 timer t3119 0 timer t3122 0 timer t3141 0 dtx-used 0 subscriber-keep-in-ram 0 bts 0 type nanobts band PCS1900 cell_identity 2611 location_area_code 51601 training_sequence_code 7 base_station_id_code 63 ms max power 15 cell reselection hysteresis 4 rxlev access min 0 channel allocator ascending rach tx integer 9 rach max transmission 7 ip.access unit_id 1801 0 oml ip.access stream_id 255 line 0 neighbor-list mode manual-si5 gprs mode none trx 0 rf_locked 0 arfcn 800 nominal power 0 max_power_red 20 rsl e1 tei 0 timeslot 0 phys_chan_config CCCH+SDCCH4 hopping enabled 0 timeslot 1 phys_chan_config TCH/F hopping enabled 0 timeslot 2 phys_chan_config TCH/F hopping enabled 0 timeslot 3 phys_chan_config TCH/F hopping enabled 0 timeslot 4 phys_chan_config TCH/F hopping enabled 0 timeslot 5 phys_chan_config TCH/F hopping enabled 0 timeslot 6 phys_chan_config TCH/F hopping enabled 0 timeslot 7 phys_chan_config TCH/F hopping enabled 0 msc ip.access rtp-base 6000 timeout-ping 20 timeout-pong 5 dest 192.168.50.10 5000 0 CRCX 147 0012 at mgw MGCP 1.0 M: sendrecv L: p:20, s: off, e: off, a: GSM C: 18 v=0 c=IN IP4 192.168.1.11 m=audio 5036 RTP/AVP 3 200 147 OK I: 6 v=0 o=- 6 23 IN IP4 192.168.1.11 c=IN IP4 192.168.1.11 t=0 0 m=audio 16036 RTP/AVP 3 a=rtpmap:3 GSM/8000 -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter at stuge.se Wed Aug 14 10:48:08 2013 From: peter at stuge.se (Peter Stuge) Date: Wed, 14 Aug 2013 12:48:08 +0200 Subject: your mail In-Reply-To: References: Message-ID: <20130814104808.9565.qmail@stuge.se> (Please make sure to always write a subject. Otherwise your email is not actually a standards conform email message. Gmail unfortunately doesn't seem to care.) Dmitri Soloviev wrote: > I'm getting an error > <000b> mgcp_network.c:348 Endpoint 0x13 data from wrong address > 192.168.1.11 vs. 0.0.0.0 .. > So, mgcp is bind to 0.0.0.0 The error messages pretty much says that this is the problem. > cause MGCP is controlled over VPN interface Create and configure IP on the VPN interface before starting OpenVPN and MGCP, and configure the actual IP in mgcp.cfg. You can tell OpenVPN to use one specific tun or tap device. Or patch the MGCP to deal with arbitrary addresses. This requires significantly more effort, but also a nice contribution. In any case maybe you can send a patch for the MGCP to not accept 0.0.0.0 in the config file, when that is a known invalid configuration. This is probably a two-line patch. //Peter From jerlbeck at sysmocom.de Wed Aug 14 09:10:34 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 14 Aug 2013 11:10:34 +0200 Subject: [PATCH] nat/ussd: Add 'show ussd-connection' vty command Message-ID: <1376471434-3090-1-git-send-email-jerlbeck@sysmocom.de> This command returns the current state of the connection to the USSD side channel provider. It shows whether a provider has been connected and authorized or not. Fixes: OW#953 --- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 15 +++++++++- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 19 +++++++++++++ openbsc/tests/vty_test_runner.py | 49 ++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 6ab48d6..04f6f5f 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -248,7 +248,7 @@ DEFUN(show_bsc_mgcp, show_bsc_mgcp_cmd, "show bsc mgcp NR", for (j = 0; j < 32; ++j) { endp = mgcp_timeslot_to_endpoint(i, j); vty_out(vty, " Endpoint 0x%x %s%s", endp, - con->_endpoint_status[endp] == 0 + con->_endpoint_status[endp] == 0 ? "free" : "allocated", VTY_NEWLINE); } @@ -1155,6 +1155,18 @@ DEFUN(cfg_pgroup_no_lac, cfg_pgroup_no_lac_cmd, return CMD_SUCCESS; } +DEFUN(show_ussd_connection, + show_ussd_connection_cmd, + "show ussd-connection", + SHOW_STR "USSD connection related information\n") +{ + vty_out(vty, "The USSD side channel provider is %sconnected and %sauthorized.%s", + _nat->ussd_con ? "" : "not ", + _nat->ussd_con && _nat->ussd_con->authorized? "" : "not ", + VTY_NEWLINE); + return CMD_SUCCESS; +} + int bsc_nat_vty_init(struct bsc_nat *nat) { _nat = nat; @@ -1172,6 +1184,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element_ve(&show_acc_lst_cmd); install_element_ve(&show_bar_lst_cmd); install_element_ve(&show_prefix_tree_cmd); + install_element_ve(&show_ussd_connection_cmd); install_element(ENABLE_NODE, &set_last_endp_cmd); install_element(ENABLE_NODE, &block_new_conn_cmd); diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c index f7753fb..d422f9e 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c +++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c @@ -69,6 +69,20 @@ static void bsc_nat_ussd_destroy(struct bsc_nat_ussd_con *con) talloc_free(con); } +static void ussd_pong(struct bsc_nat_ussd_con *conn) +{ + struct msgb *msg; + + msg = msgb_alloc_headroom(4096, 128, "pong message"); + if (!msg) { + LOGP(DNAT, LOGL_ERROR, "Failed to allocate pong msg\n"); + return; + } + + msgb_v_put(msg, IPAC_MSGT_PONG); + bsc_do_write(&conn->queue, msg, IPAC_PROTO_IPACCESS); +} + static int forward_sccp(struct bsc_nat *nat, struct msgb *msg) { struct nat_sccp_connection *con; @@ -133,6 +147,11 @@ static int ussd_read_cb(struct osmo_fd *bfd) } if (TLVP_PRESENT(&tvp, IPAC_IDTAG_UNITNAME)) ussd_auth_con(&tvp, conn); + } else if (msg->l2h[0] == IPAC_MSGT_PING) { + LOGP(DNAT, LOGL_DEBUG, "Got USSD ping request.\n"); + ussd_pong(conn); + } else { + LOGP(DNAT, LOGL_NOTICE, "Got unknown IPACCESS message 0x%02x.\n", msg->l2h[0]); } msgb_free(msg); diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 730b8ba..210bd42 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -18,6 +18,7 @@ import os import time import unittest +import socket import osmopy.obscvty as obscvty import osmopy.osmoutil as osmoutil @@ -132,6 +133,54 @@ class TestVTYNAT(TestVTYBase): res = self.vty.command("show prefix-tree") self.assertEqual(res, "% there is now prefix tree loaded.") + def testUssdSideChannelProvider(self): + self.vty.command("end") + self.vty.enable() + self.vty.command("configure terminal") + self.vty.command("nat") + self.vty.command("ussd-token key") + self.vty.command("end") + + res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is not connected and not authorized.']) + self.assertEqual(res, True) + + ussdSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + ussdSocket.connect(('127.0.0.1', 5001)) + ussdSocket.settimeout(2.0) + print "Connected to %s:%d" % ussdSocket.getpeername() + + print "Expecting ID_GET request" + data = ussdSocket.recv(4) + self.assertEqual(data, "\x00\x01\xfe\x04") + + print "Going to send ID_RESP response" + res = ussdSocket.send("\x00\x07\xfe\x05\x00\x04\x01\x6b\x65\x79") + self.assertEqual(res, 10) + + # initiating PING/PONG cycle to know, that the ID_RESP message has been processed + + print "Going to send PING request" + res = ussdSocket.send("\x00\x01\xfe\x00") + self.assertEqual(res, 4) + + print "Expecting PONG response" + data = ussdSocket.recv(4) + self.assertEqual(data, "\x00\x01\xfe\x01") + + res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is connected and authorized.']) + self.assertEqual(res, True) + + print "Going to shut down connection" + ussdSocket.shutdown(socket.SHUT_WR) + + print "Expecting EOF" + data = ussdSocket.recv(4) + self.assertEqual(data, "") + + ussdSocket.close() + + res = self.vty.verify("show ussd-connection", ['The USSD side channel provider is not connected and not authorized.']) + self.assertEqual(res, True) def add_nat_test(suite, workdir): if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc_nat/osmo-bsc_nat")): -- 1.7.9.5 From holger at freyther.de Wed Aug 14 09:25:13 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 14 Aug 2013 11:25:13 +0200 Subject: [PATCH] nat/ussd: Add 'show ussd-connection' vty command In-Reply-To: <1376471434-3090-1-git-send-email-jerlbeck@sysmocom.de> References: <1376471434-3090-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130814092513.GA19155@xiaoyu.lan> On Wed, Aug 14, 2013 at 11:10:34AM +0200, Jacob Erlbeck wrote: > > + self.assertEqual(res, True) did you consider assertTrue? From jerlbeck at sysmocom.de Wed Aug 14 10:26:27 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 14 Aug 2013 12:26:27 +0200 Subject: [PATCH] core: Move OSMO_DEPRECATED to new core/defs.h file Message-ID: <1376475987-7631-1-git-send-email-jerlbeck@sysmocom.de> Add a new core/defs.h file for definitions that can be used from within header files without including prototypes and extern declarations. It's primarily meant for macro definitions and basic typedefs. Move the definition of OSMO_DEPRECATED there and use compiler version info to avoid compiler errors. --- include/osmocom/core/defs.h | 39 +++++++++++++++++++++++++++++++++++++++ include/osmocom/gsm/gsm_utils.h | 14 +------------- 2 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 include/osmocom/core/defs.h diff --git a/include/osmocom/core/defs.h b/include/osmocom/core/defs.h new file mode 100644 index 0000000..e3afbff --- /dev/null +++ b/include/osmocom/core/defs.h @@ -0,0 +1,39 @@ +#ifndef OSMOCORE_DEFS_H +#define OSMOCORE_DEFS_H + +/*! \defgroup utils General-purpose utility functions + * @{ + */ + +/*! \file defs.h + * \brief General definitions that are meant to be included from header files. + */ + +/*! \brief Check for gcc and version. + * + * \note Albeit glibc provides a features.h file that contains a similar + * definition (__GNUC_PREREQ), this definition has been copied from there + * to have it available with other libraries, too. + * + * \return != 0 iff gcc is used and it's version is at least maj.min. + */ +#if defined __GNUC__ && defined __GNUC_MINOR__ +# define OSMO_GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define OSMO_GNUC_PREREQ(maj, min) 0 +#endif + +/*! \brief Set the deprecated attribute with a message. + */ +#if ! defined(__GNUC__) +# define OSMO_DEPRECATED(text) +#elif OSMO_GNUC_PREREQ(4,5) +# define OSMO_DEPRECATED(text) __attribute__((__deprecated__(text))) +#else +# define OSMO_DEPRECATED(text) __attribute__((__deprecated__)) +#endif + +/*! @} */ + +#endif diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 1c55dfb..f412e3e 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -28,7 +28,7 @@ #include #include -#include +#include #define ADD_MODULO(sum, delta, modulo) do { \ if ((sum += delta) >= modulo) \ @@ -37,18 +37,6 @@ #define GSM_MAX_FN (26*51*2048) -/*! \brief Set the deprecated attribute with a message. - * - * \todo Move this to a global header utility file. - * \todo Check for compiler version to selectivly enable the message. - */ -#if 0 -#define OSMO_DEPRECATED(text) __attribute__((deprecated(text))) -#else -#define OSMO_DEPRECATED(text) __attribute__((__deprecated__)) -#endif - - struct gsm_time { uint32_t fn; /* FN count */ uint16_t t1; /* FN div (26*51) */ -- 1.7.9.5 From pablo at gnumonks.org Wed Aug 14 13:55:45 2013 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Wed, 14 Aug 2013 15:55:45 +0200 Subject: [PATCH openbsc] libmgcp: add mgcp prefix to functions and constants Message-ID: <1376488546-10571-1-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Functions and constants that belong to the libmgcp scope are prefixed with mgcp_ and MGCP_. This patch is a cleanup. --- openbsc/src/libmgcp/mgcp_network.c | 70 +++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index e9b58b2..a70acfb 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -80,16 +80,16 @@ struct rtp_hdr { enum { - DEST_NETWORK = 0, - DEST_BTS = 1, + MGCP_DEST_NET = 0, + MGCP_DEST_BTS, }; enum { - PROTO_RTP, - PROTO_RTCP, + MGCP_PROTO_RTP, + MGCP_PROTO_RTCP, }; -#define DUMMY_LOAD 0x23 +#define MGCP_DUMMY_LOAD 0x23 /** @@ -127,7 +127,7 @@ static int udp_send(int fd, struct in_addr *addr, int port, char *buf, int len) int mgcp_send_dummy(struct mgcp_endpoint *endp) { - static char buf[] = { DUMMY_LOAD }; + static char buf[] = { MGCP_DUMMY_LOAD }; return udp_send(endp->net_end.rtp.fd, &endp->net_end.addr, endp->net_end.rtp_port, buf, 1); @@ -237,8 +237,9 @@ static int forward_data(int fd, struct mgcp_rtp_tap *tap, const char *buf, int l (struct sockaddr *)&tap->forward, sizeof(tap->forward)); } -static int send_transcoder(struct mgcp_rtp_end *end, struct mgcp_config *cfg, - int is_rtp, const char *buf, int len) +static int mgcp_send_transcoder(struct mgcp_rtp_end *end, + struct mgcp_config *cfg, int is_rtp, + const char *buf, int len) { int rc; int port; @@ -263,8 +264,8 @@ static int send_transcoder(struct mgcp_rtp_end *end, struct mgcp_config *cfg, return rc; } -static int send_to(struct mgcp_endpoint *endp, int dest, int is_rtp, - struct sockaddr_in *addr, char *buf, int rc) +static int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp, + struct sockaddr_in *addr, char *buf, int rc) { struct mgcp_trunk_config *tcfg = endp->tcfg; /* For loop toggle the destination and then dispatch. */ @@ -275,7 +276,7 @@ static int send_to(struct mgcp_endpoint *endp, int dest, int is_rtp, if (endp->conn_mode == MGCP_CONN_LOOPBACK) dest = !dest; - if (dest == DEST_NETWORK) { + if (dest == MGCP_DEST_NET) { if (is_rtp) { patch_and_count(endp, &endp->bts_state, endp->net_end.payload_type, @@ -360,13 +361,13 @@ static int rtp_data_net(struct osmo_fd *fd, unsigned int what) } /* throw away the dummy message */ - if (rc == 1 && buf[0] == DUMMY_LOAD) { + if (rc == 1 && buf[0] == MGCP_DUMMY_LOAD) { LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy from network on 0x%x\n", ENDPOINT_NUMBER(endp)); return 0; } - proto = fd == &endp->net_end.rtp ? PROTO_RTP : PROTO_RTCP; + proto = fd == &endp->net_end.rtp ? MGCP_PROTO_RTP : MGCP_PROTO_RTCP; endp->net_end.packets += 1; endp->net_end.octets += rc; @@ -374,11 +375,11 @@ static int rtp_data_net(struct osmo_fd *fd, unsigned int what) switch (endp->type) { case MGCP_RTP_DEFAULT: - return send_to(endp, DEST_BTS, proto == PROTO_RTP, &addr, - buf, rc); + return mgcp_send(endp, MGCP_DEST_BTS, proto == MGCP_PROTO_RTP, + &addr, buf, rc); case MGCP_RTP_TRANSCODED: - return send_transcoder(&endp->trans_net, endp->cfg, - proto == PROTO_RTP, buf, rc); + return mgcp_send_transcoder(&endp->trans_net, endp->cfg, + proto == MGCP_PROTO_RTP, buf, rc); } LOGP(DMGCP, LOGL_ERROR, "Bad MGCP type %u on endpoint %u\n", @@ -390,7 +391,7 @@ static void discover_bts(struct mgcp_endpoint *endp, int proto, struct sockaddr_ { struct mgcp_config *cfg = endp->cfg; - if (proto == PROTO_RTP && endp->bts_end.rtp_port == 0) { + if (proto == MGCP_PROTO_RTP && endp->bts_end.rtp_port == 0) { if (!cfg->bts_ip || memcmp(&addr->sin_addr, &cfg->bts_in, sizeof(cfg->bts_in)) == 0 || @@ -405,7 +406,7 @@ static void discover_bts(struct mgcp_endpoint *endp, int proto, struct sockaddr_ ENDPOINT_NUMBER(endp), ntohs(endp->bts_end.rtp_port), ntohs(endp->bts_end.rtcp_port), inet_ntoa(addr->sin_addr)); } - } else if (proto == PROTO_RTCP && endp->bts_end.rtcp_port == 0) { + } else if (proto == MGCP_PROTO_RTCP && endp->bts_end.rtcp_port == 0) { if (memcmp(&endp->bts_end.addr, &addr->sin_addr, sizeof(endp->bts_end.addr)) == 0) { endp->bts_end.rtcp_port = addr->sin_port; @@ -426,7 +427,7 @@ static int rtp_data_bts(struct osmo_fd *fd, unsigned int what) if (rc <= 0) return -1; - proto = fd == &endp->bts_end.rtp ? PROTO_RTP : PROTO_RTCP; + proto = fd == &endp->bts_end.rtp ? MGCP_PROTO_RTP : MGCP_PROTO_RTCP; /* We have no idea who called us, maybe it is the BTS. */ /* it was the BTS... */ @@ -448,7 +449,7 @@ static int rtp_data_bts(struct osmo_fd *fd, unsigned int what) } /* throw away the dummy message */ - if (rc == 1 && buf[0] == DUMMY_LOAD) { + if (rc == 1 && buf[0] == MGCP_DUMMY_LOAD) { LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy from bts on 0x%x\n", ENDPOINT_NUMBER(endp)); return 0; @@ -462,11 +463,11 @@ static int rtp_data_bts(struct osmo_fd *fd, unsigned int what) switch (endp->type) { case MGCP_RTP_DEFAULT: - return send_to(endp, DEST_NETWORK, proto == PROTO_RTP, &addr, - buf, rc); + return mgcp_send(endp, MGCP_DEST_NET, proto == MGCP_PROTO_RTP, + &addr, buf, rc); case MGCP_RTP_TRANSCODED: - return send_transcoder(&endp->trans_bts, endp->cfg, - proto == PROTO_RTP, buf, rc); + return mgcp_send_transcoder(&endp->trans_bts, endp->cfg, + proto == MGCP_PROTO_RTP, buf, rc); } LOGP(DMGCP, LOGL_ERROR, "Bad MGCP type %u on endpoint %u\n", @@ -487,7 +488,7 @@ static int rtp_data_transcoder(struct mgcp_rtp_end *end, struct mgcp_endpoint *_ if (rc <= 0) return -1; - proto = fd == &end->rtp ? PROTO_RTP : PROTO_RTCP; + proto = fd == &end->rtp ? MGCP_PROTO_RTP : MGCP_PROTO_RTCP; if (memcmp(&addr.sin_addr, &cfg->transcoder_in, sizeof(addr.sin_addr)) != 0) { LOGP(DMGCP, LOGL_ERROR, @@ -505,14 +506,14 @@ static int rtp_data_transcoder(struct mgcp_rtp_end *end, struct mgcp_endpoint *_ } /* throw away the dummy message */ - if (rc == 1 && buf[0] == DUMMY_LOAD) { + if (rc == 1 && buf[0] == MGCP_DUMMY_LOAD) { LOGP(DMGCP, LOGL_NOTICE, "Filtered dummy from transcoder dest %d on 0x%x\n", dest, ENDPOINT_NUMBER(_endp)); return 0; } end->packets += 1; - return send_to(_endp, dest, proto == PROTO_RTP, &addr, &buf[0], rc); + return mgcp_send(_endp, dest, proto == MGCP_PROTO_RTP, &addr, buf, rc); } static int rtp_data_trans_net(struct osmo_fd *fd, unsigned int what) @@ -520,7 +521,7 @@ static int rtp_data_trans_net(struct osmo_fd *fd, unsigned int what) struct mgcp_endpoint *endp; endp = (struct mgcp_endpoint *) fd->data; - return rtp_data_transcoder(&endp->trans_net, endp, DEST_NETWORK, fd); + return rtp_data_transcoder(&endp->trans_net, endp, MGCP_DEST_NET, fd); } static int rtp_data_trans_bts(struct osmo_fd *fd, unsigned int what) @@ -528,10 +529,11 @@ static int rtp_data_trans_bts(struct osmo_fd *fd, unsigned int what) struct mgcp_endpoint *endp; endp = (struct mgcp_endpoint *) fd->data; - return rtp_data_transcoder(&endp->trans_bts, endp, DEST_BTS, fd); + return rtp_data_transcoder(&endp->trans_bts, endp, MGCP_DEST_BTS, fd); } -static int create_bind(const char *source_addr, struct osmo_fd *fd, int port) +static int mgcp_create_bind(const char *source_addr, struct osmo_fd *fd, + int port) { struct sockaddr_in addr; int on = 1; @@ -567,13 +569,15 @@ static int set_ip_tos(int fd, int tos) static int bind_rtp(struct mgcp_config *cfg, struct mgcp_rtp_end *rtp_end, int endpno) { - if (create_bind(cfg->source_addr, &rtp_end->rtp, rtp_end->local_port) != 0) { + if (mgcp_create_bind(cfg->source_addr, &rtp_end->rtp, + rtp_end->local_port) != 0) { LOGP(DMGCP, LOGL_ERROR, "Failed to create RTP port: %s:%d on 0x%x\n", cfg->source_addr, rtp_end->local_port, endpno); goto cleanup0; } - if (create_bind(cfg->source_addr, &rtp_end->rtcp, rtp_end->local_port + 1) != 0) { + if (mgcp_create_bind(cfg->source_addr, &rtp_end->rtcp, + rtp_end->local_port + 1) != 0) { LOGP(DMGCP, LOGL_ERROR, "Failed to create RTCP port: %s:%d on 0x%x\n", cfg->source_addr, rtp_end->local_port + 1, endpno); goto cleanup1; -- 1.7.10.4 From holger at freyther.de Wed Aug 14 14:20:29 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 14 Aug 2013 16:20:29 +0200 Subject: [PATCH openbsc] libmgcp: add mgcp prefix to functions and constants In-Reply-To: <1376488546-10571-1-git-send-email-pablo@gnumonks.org> References: <1376488546-10571-1-git-send-email-pablo@gnumonks.org> Message-ID: <20130814142029.GB22539@xiaoyu.lan> On Wed, Aug 14, 2013 at 03:55:45PM +0200, pablo at gnumonks.org wrote: > From: Pablo Neira Ayuso > > Functions and constants that belong to the libmgcp scope are prefixed > with mgcp_ and MGCP_. This patch is a cleanup. thanks, I have applied it locally. Could you please explain "why" it is needed? Did you have a clash or is it just a general cleanup? cheers holger From pablo at gnumonks.org Wed Aug 14 21:40:35 2013 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Wed, 14 Aug 2013 23:40:35 +0200 Subject: [PATCH openbsc] libmgcp: add mgcp prefix to functions and constants In-Reply-To: <20130814142029.GB22539@xiaoyu.lan> References: <1376488546-10571-1-git-send-email-pablo@gnumonks.org> <20130814142029.GB22539@xiaoyu.lan> Message-ID: <20130814214035.GA4722@localhost> On Wed, Aug 14, 2013 at 04:20:29PM +0200, Holger Hans Peter Freyther wrote: > On Wed, Aug 14, 2013 at 03:55:45PM +0200, pablo at gnumonks.org wrote: > > From: Pablo Neira Ayuso > > > > Functions and constants that belong to the libmgcp scope are prefixed > > with mgcp_ and MGCP_. This patch is a cleanup. > > thanks, I have applied it locally. Could you please explain "why" it is > needed? Did you have a clash or is it just a general cleanup? It's a cleanup to prepare a follow up patch. I was trying to avoid the function/constant rename in such patch. From risky at mail.ru Wed Aug 14 15:42:30 2013 From: risky at mail.ru (Sergey V. Efimov) Date: Wed, 14 Aug 2013 19:42:30 +0400 Subject: OpenBSC GPRS Question Message-ID: Hello All, Tried to setup Osmo-NITB + OsmoSGSN + GGSN installation using sysmoBTS station. To connect to the network I use custom SIM card programmed with appropriate MCC and MNC. That is what I get: osmo-nitb log: ==================== <0005> abis_nm.c:2414 OC=GPRS-CELL(f1) INST=(00,00,ff) IPACCESS(0xf6): SET ATTR ACK <0005> abis_nm.c:2414 OC=GPRS-NSVC(f2) INST=(00,00,ff) IPACCESS(0xf6): SET ATTR ACK <0004> abis_rsl.c:1431 (bts=0,trx=0,ts=0,ss=0) Activating ARFCN(666) SS(0) lctype SDCCH r=LOCATION_UPDATE ra=0x0f ta=0 <0004> abis_rsl.c:1165 (bts=0,trx=0,ts=0,ss=0) CHANNEL ACTIVATE ACK <0000> abis_rsl.c:1621 (bts=0,trx=0,ts=0,ss=0) SAPI=0 ESTABLISH INDICATION <0002> gsm_04_08.c:1055 LOCATION UPDATING REQUEST: mi_type=0x01 MI(250770000002339) type=NORMAL <0001> gsm_04_08.c:119 (bts 0 trx 0 ts 0 pd 05) Sending 0x18 to MS. <0000> abis_rsl.c:1621 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION <0003> bsc_api.c:479 CLASSMARK CHANGE CM2(len=3) CM3(len=9) <0000> abis_rsl.c:1621 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION <0002> gsm_04_08.c:462 IDENTITY RESPONSE: mi_type=0x02 MI(358279013039780) <0002> gsm_04_08.c:426 -> LOCATION UPDATE ACCEPT <0001> gsm_04_08.c:119 (bts 0 trx 0 ts 0 pd 05) Sending 0x02 to MS. <0002> gsm_04_08.c:768 -> MM INFO <0001> gsm_04_08.c:119 (bts 0 trx 0 ts 0 pd 05) Sending 0x32 to MS. <0002> gsm_subscriber.c:361 Subscriber 250770000002339 ATTACHED LAC=1 <0000> abis_rsl.c:1621 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION <0002> gsm_04_08.c:1071 TMSI Reallocation Completed. Subscriber: 250770000002339 <0000> chan_alloc.c:405 (bts=0,trx=0,ts=0,ss=0) starting release sequence <0003> gsm_04_08_utils.c:231 Sending Channel Release: Chan: Number: 0 Type: 1 <0004> abis_rsl.c:633 (bts=0,trx=0,ts=0,ss=0) DEACTivate SACCH CMD <0000> abis_rsl.c:1621 (bts=0,trx=0,ts=0,ss=0) SAPI=0 RELEASE INDICATION <0004> abis_rsl.c:679 (bts=0,trx=0,ts=0,ss=0) RF Channel Release CMD due error 0 <0004> abis_rsl.c:731 (bts=0,trx=0,ts=0,ss=0) RF CHANNEL RELEASE ACK ===================== Thus, I see that GPRS attributes were set successfully and the subscriber was granted access to the network. Then, I look into osmo-sgsn log: ===================== <0010> gprs_ns.c:679 NSEI=101 Rx NS RESET (NSVCI=101, cause=O&M intervention) <0010> gprs_ns.c:538 NSEI=101 Tx NS RESET ACK (NSVCI=101) <0010> gprs_ns.c:679 NSEI=101 Rx NS RESET (NSVCI=101, cause=PDU not compatible with protocol state) <0010> gprs_ns.c:538 NSEI=101 Tx NS RESET ACK (NSVCI=101) <0010> gprs_ns.c:865 NSEI=101 Rx NS UNBLOCK <0010> gprs_ns.c:865 NSEI=101 Rx NS UNBLOCK <0011> gprs_bssgp.c:1000 NSEI=101/BVCI=2 Rejecting PDU type 1 for unknown BVCI <0011> gprs_bssgp_util.c:103 BSSGP BVCI=0 Tx STATUS, cause=Unknown BVCI <0011> gprs_bssgp.c:1000 NSEI=101/BVCI=2 Rejecting PDU type 1 for unknown BVCI <0011> gprs_bssgp_util.c:103 BSSGP BVCI=0 Tx STATUS, cause=Unknown BVCI ===================== So, PDU is rejected and I don't see any GPRS availability on a phone. Has anybody ever seen this message? Regards, Sergey. From holger at freyther.de Wed Aug 14 16:17:55 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 14 Aug 2013 18:17:55 +0200 Subject: OpenBSC GPRS Question In-Reply-To: References: Message-ID: <20130814161755.GD22539@xiaoyu.lan> On Wed, Aug 14, 2013 at 07:42:30PM +0400, Sergey V. Efimov wrote: > Hello All, > > <0011> gprs_bssgp.c:1000 NSEI=101/BVCI=2 Rejecting PDU type 1 for unknown BVCI > <0011> gprs_bssgp_util.c:103 BSSGP BVCI=0 Tx STATUS, cause=Unknown BVCI > <0011> gprs_bssgp.c:1000 NSEI=101/BVCI=2 Rejecting PDU type 1 for unknown BVCI > <0011> gprs_bssgp_util.c:103 BSSGP BVCI=0 Tx STATUS, cause=Unknown BVCI without your NITB/BSC config it is difficult to judge. What doesn't work for sure is to restart the SGSN once the PCU has exchanged some messages with it. holger From risky at mail.ru Wed Aug 14 17:49:43 2013 From: risky at mail.ru (Sergey V. Efimov) Date: Wed, 14 Aug 2013 21:49:43 +0400 Subject: OpenBSC GPRS Question In-Reply-To: <20130814161755.GD22539@xiaoyu.lan> References: <20130814161755.GD22539@xiaoyu.lan> Message-ID: <0DFD38E3-2955-478E-8E54-1207C6EC270A@mail.ru> Hello, I used step-by-step instruction from the osmocom.org site. Here is my openbsc config: ==== e1_input e1_line 0 driver ipa network network country code 250 mobile network code 77 short name ABC long name ABC auth policy accept-all location updating reject cause 13 encryption a5 0 neci 1 rrlp mode none mm info 1 handover 0 handover window rxlev averaging 10 handover window rxqual averaging 1 handover window rxlev neighbor averaging 10 handover power budget interval 6 handover power budget hysteresis 3 handover maximum distance 9999 timer t3101 10 timer t3103 0 timer t3105 0 timer t3107 0 timer t3109 4 timer t3111 0 timer t3113 60 timer t3115 0 timer t3117 0 timer t3119 0 timer t3141 0 bts 0 type nanobts band DCS1800 cell_identity 0 location_area_code 1 training_sequence_code 7 base_station_id_code 63 ms max power 15 cell reselection hysteresis 4 rxlev access min 0 channel allocator ascending rach tx integer 9 rach max transmission 7 ip.access unit_id 1234 0 oml ip.access stream_id 255 line 0 gprs mode gprs gprs routing area 0 gprs cell bvci 2 gprs nsei 101 gprs nsvc 0 nsvci 101 gprs nsvc 0 local udp port 23000 gprs nsvc 0 remote udp port 23000 gprs nsvc 0 remote ip 192.168.168.98 trx 0 rf_locked 0 arfcn 666 nominal power 23 max_power_red 20 rsl e1 tei 0 timeslot 0 phys_chan_config CCCH+SDCCH4 timeslot 1 phys_chan_config PDCH timeslot 2 phys_chan_config PDCH timeslot 3 phys_chan_config TCH/F timeslot 4 phys_chan_config TCH/F timeslot 5 phys_chan_config TCH/F timeslot 6 phys_chan_config TCH/F timeslot 7 phys_chan_config TCH/F ==== Here is my osmo-sgsn.cfg ==== sgsn gtp local-ip 192.168.168.98 ggsn 0 remote-ip 192.168.168.230 ggsn 0 gtp-version 1 ! ns timer tns-block 3 timer tns-block-retries 3 timer tns-reset 3 timer tns-reset-retries 3 timer tns-test 30 timer tns-alive 3 timer tns-alive-retries 10 encapsulation udp local-ip 192.168.168.98 encapsulation udp local-port 23000 encapsulation framerelay-gre enabled 0 ==== Here is my ggsn.cfg === listen 192.168.168.230 net 192.168.168.0/24 dynip 192.168.168.240/30 === Here is my open-bts.cfg === bts 0 band 1800 ipa unit-id 1234 0 oml remote-ip 192.168.168.98 === Regards, Sergey. On Aug 14, 2013, at 8:17 PM, Holger Hans Peter Freyther wrote: > On Wed, Aug 14, 2013 at 07:42:30PM +0400, Sergey V. Efimov wrote: >> Hello All, >> >> <0011> gprs_bssgp.c:1000 NSEI=101/BVCI=2 Rejecting PDU type 1 for unknown BVCI >> <0011> gprs_bssgp_util.c:103 BSSGP BVCI=0 Tx STATUS, cause=Unknown BVCI >> <0011> gprs_bssgp.c:1000 NSEI=101/BVCI=2 Rejecting PDU type 1 for unknown BVCI >> <0011> gprs_bssgp_util.c:103 BSSGP BVCI=0 Tx STATUS, cause=Unknown BVCI > > without your NITB/BSC config it is difficult to judge. What doesn't work for > sure is to restart the SGSN once the PCU has exchanged some messages with it. > > > holger > > From risky at mail.ru Thu Aug 15 13:12:39 2013 From: risky at mail.ru (Sergey V. Efimov) Date: Thu, 15 Aug 2013 17:12:39 +0400 Subject: OpenBSC GPRS Question In-Reply-To: References: <20130814161755.GD22539@xiaoyu.lan> <0DFD38E3-2955-478E-8E54-1207C6EC270A@mail.ru> Message-ID: <1B96A0E8-1739-4A38-91A9-5793E1929731@mail.ru> Hello, Tried port and got message: <0010> gprs_nc.c:627 NSEI=101 Rx NS STATUS cause=PDU not compatible with protocol state <0010> gprs_nc.c:489 NSEI=101 Tns-alive expired more than 10 times, blocking NS-VC And nothing has changed, still get Rejecting PDU for unknown BVCI. Could you please provide me your config files which are working? Regards, Sergey. On Aug 14, 2013, at 10:03 PM, altaf sk wrote: > Hey > > Try using > gprs nsvc 0 remote udp port 5948 > > It worked for me > > Let me know what happens > > Regards > > Altaf > > On Aug 14, 2013 7:52 PM, "Sergey V. Efimov" wrote: > Hello, > > I used step-by-step instruction from the osmocom.org site. > > Here is my openbsc config: > > ==== > e1_input > e1_line 0 driver ipa > network > network country code 250 > mobile network code 77 > short name ABC > long name ABC > auth policy accept-all > location updating reject cause 13 > encryption a5 0 > neci 1 > rrlp mode none > mm info 1 > handover 0 > handover window rxlev averaging 10 > handover window rxqual averaging 1 > handover window rxlev neighbor averaging 10 > handover power budget interval 6 > handover power budget hysteresis 3 > handover maximum distance 9999 > timer t3101 10 > timer t3103 0 > timer t3105 0 > timer t3107 0 > timer t3109 4 > timer t3111 0 > timer t3113 60 > timer t3115 0 > timer t3117 0 > timer t3119 0 > timer t3141 0 > bts 0 > type nanobts > band DCS1800 > cell_identity 0 > location_area_code 1 > training_sequence_code 7 > base_station_id_code 63 > ms max power 15 > cell reselection hysteresis 4 > rxlev access min 0 > channel allocator ascending > rach tx integer 9 > rach max transmission 7 > ip.access unit_id 1234 0 > oml ip.access stream_id 255 line 0 > gprs mode gprs > gprs routing area 0 > gprs cell bvci 2 > gprs nsei 101 > gprs nsvc 0 nsvci 101 > gprs nsvc 0 local udp port 23000 > gprs nsvc 0 remote udp port 23000 > gprs nsvc 0 remote ip 192.168.168.98 > trx 0 > rf_locked 0 > arfcn 666 > nominal power 23 > max_power_red 20 > rsl e1 tei 0 > timeslot 0 > phys_chan_config CCCH+SDCCH4 > timeslot 1 > phys_chan_config PDCH > timeslot 2 > phys_chan_config PDCH > timeslot 3 > phys_chan_config TCH/F > timeslot 4 > phys_chan_config TCH/F > timeslot 5 > phys_chan_config TCH/F > timeslot 6 > phys_chan_config TCH/F > timeslot 7 > phys_chan_config TCH/F > ==== > > Here is my osmo-sgsn.cfg > > ==== > sgsn > gtp local-ip 192.168.168.98 > ggsn 0 remote-ip 192.168.168.230 > ggsn 0 gtp-version 1 > ! > ns > timer tns-block 3 > timer tns-block-retries 3 > timer tns-reset 3 > timer tns-reset-retries 3 > timer tns-test 30 > timer tns-alive 3 > timer tns-alive-retries 10 > encapsulation udp local-ip 192.168.168.98 > encapsulation udp local-port 23000 > encapsulation framerelay-gre enabled 0 > > ==== > > Here is my ggsn.cfg > > === > listen 192.168.168.230 > net 192.168.168.0/24 > dynip 192.168.168.240/30 > === > > Here is my open-bts.cfg > > === > bts 0 > band 1800 > ipa unit-id 1234 0 > oml remote-ip 192.168.168.98 > === > > Regards, > Sergey. > > On Aug 14, 2013, at 8:17 PM, Holger Hans Peter Freyther wrote: > > > On Wed, Aug 14, 2013 at 07:42:30PM +0400, Sergey V. Efimov wrote: > >> Hello All, > >> > >> <0011> gprs_bssgp.c:1000 NSEI=101/BVCI=2 Rejecting PDU type 1 for unknown BVCI > >> <0011> gprs_bssgp_util.c:103 BSSGP BVCI=0 Tx STATUS, cause=Unknown BVCI > >> <0011> gprs_bssgp.c:1000 NSEI=101/BVCI=2 Rejecting PDU type 1 for unknown BVCI > >> <0011> gprs_bssgp_util.c:103 BSSGP BVCI=0 Tx STATUS, cause=Unknown BVCI > > > > without your NITB/BSC config it is difficult to judge. What doesn't work for > > sure is to restart the SGSN once the PCU has exchanged some messages with it. > > > > > > holger > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerlbeck at sysmocom.de Wed Aug 14 16:13:45 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 14 Aug 2013 18:13:45 +0200 Subject: [PATCH 1/2] core: Support clang with OSME_DEPRECATED Message-ID: <1376496826-22663-1-git-send-email-jerlbeck@sysmocom.de> Separate feature checking from implementation. Supported are clang and gcc. --- include/osmocom/core/defs.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/include/osmocom/core/defs.h b/include/osmocom/core/defs.h index e3afbff..917a8c3 100644 --- a/include/osmocom/core/defs.h +++ b/include/osmocom/core/defs.h @@ -26,14 +26,25 @@ /*! \brief Set the deprecated attribute with a message. */ -#if ! defined(__GNUC__) -# define OSMO_DEPRECATED(text) -#elif OSMO_GNUC_PREREQ(4,5) +#if defined(__clang__) +# define _OSMO_HAS_ATTRIBUTE_DEPRECATED __has_attribute(deprecated) +# define _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE __has_extension(attribute_deprecated_with_message) +#elif defined(__GNUC__) +# define _OSMO_HAS_ATTRIBUTE_DEPRECATED 1 +# define _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE OSMO_GNUC_PREREQ(4,5) +#endif + +#if defined(_OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE) # define OSMO_DEPRECATED(text) __attribute__((__deprecated__(text))) -#else +#elif defined(_OSMO_HAS_ATTRIBUTE_DEPRECATED) # define OSMO_DEPRECATED(text) __attribute__((__deprecated__)) +#else +# define OSMO_DEPRECATED(text) #endif +#undef _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE +#undef _OSMO_HAS_ATTRIBUTE_DEPRECATED + /*! @} */ #endif -- 1.7.9.5 From jerlbeck at sysmocom.de Wed Aug 14 16:13:46 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 14 Aug 2013 18:13:46 +0200 Subject: [PATCH 2/2] conv: Fix main() of conv_test to compile with clang. In-Reply-To: <1376496826-22663-1-git-send-email-jerlbeck@sysmocom.de> References: <1376496826-22663-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1376496826-22663-2-git-send-email-jerlbeck@sysmocom.de> Fix type of argument 'argv'. Addresses: conv/conv_test.c:358:5: error: second parameter of 'main' (argument array) must be of type 'char **' int main(int argc, char argv[]) --- tests/conv/conv_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/conv/conv_test.c b/tests/conv/conv_test.c index 54e043e..ab651d4 100644 --- a/tests/conv/conv_test.c +++ b/tests/conv/conv_test.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -355,7 +356,7 @@ sbit_to_ubit(ubit_t *dst, sbit_t *src, int n) } -int main(int argc, char argv[]) +int main(int argc, char *argv[]) { const struct conv_test_vector *tst; ubit_t *bu0, *bu1; -- 1.7.9.5 From holger at freyther.de Wed Aug 14 18:24:18 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 14 Aug 2013 20:24:18 +0200 Subject: [PATCH 1/2] core: Support clang with OSME_DEPRECATED In-Reply-To: <1376496826-22663-1-git-send-email-jerlbeck@sysmocom.de> References: <1376496826-22663-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130814182418.GM22539@xiaoyu.lan> On Wed, Aug 14, 2013 at 06:13:45PM +0200, Jacob Erlbeck wrote: > Separate feature checking from implementation. Supported are clang and > +# define _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE OSMO_GNUC_PREREQ(4,5) > +#if defined(_OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE) we both got it wrong. it needs to be #if _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE > 0 because we unconditionally define these two for gcc and clang. :} From jerlbeck at sysmocom.de Thu Aug 15 07:39:48 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 15 Aug 2013 09:39:48 +0200 Subject: [PATCH 1/2] core: Support clang with OSME_DEPRECATED In-Reply-To: <20130814182418.GM22539@xiaoyu.lan> References: <1376496826-22663-1-git-send-email-jerlbeck@sysmocom.de> <20130814182418.GM22539@xiaoyu.lan> Message-ID: <520C85C4.3090003@sysmocom.de> On 08/14/2013 08:24 PM, Holger Hans Peter Freyther wrote: > On Wed, Aug 14, 2013 at 06:13:45PM +0200, Jacob Erlbeck wrote: > > > +#if defined(_OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE) > we both got it wrong. it needs to be #if _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE > 0 > because we unconditionally define these two for gcc and clang. :} > No, it's just '#if _OSMO_HAS_FOO' since non-macro identifiers are considered 0 (according to 'info cpp'). I've verified this with gcc and clang. And I've installed gcc-4.4 to check stuff like this before jenkins does. Jacob From choukoumoun at gmail.com Wed Aug 14 21:05:32 2013 From: choukoumoun at gmail.com (choukoumoun) Date: Wed, 14 Aug 2013 23:05:32 +0200 Subject: RF connector name Nanobts 139U Message-ID: <520BF11C.7030604@gmail.com> Hello, What is the reference of the 2 RF connector in the nanoBTS 139U? Best, Choukoumoun. * Anglais - d?tect? * Anglais * Anglais -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerlbeck at sysmocom.de Thu Aug 15 08:38:05 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Thu, 15 Aug 2013 10:38:05 +0200 Subject: [PATCH] core: Remove defined() check for OSMO_DEPRECATE Message-ID: <1376555885-19184-1-git-send-email-jerlbeck@sysmocom.de> This reverts commit bf991bc0f3006eddf45d494ee7e476a75dbaf36e and fixes the bug instead. It's just sufficient to remove the defined() test, since identifiers that aren't macros are just considered as 0 when used with #if. (see cpp info page, section 4.2.2 'If' in cpp-4.6.info) --- include/osmocom/core/defs.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/include/osmocom/core/defs.h b/include/osmocom/core/defs.h index ca12a80..5ffee04 100644 --- a/include/osmocom/core/defs.h +++ b/include/osmocom/core/defs.h @@ -27,22 +27,16 @@ /*! \brief Set the deprecated attribute with a message. */ #if defined(__clang__) -# if __has_attribute(deprecated) -# define _OSMO_HAS_ATTRIBUTE_DEPRECATED 1 -# endif -# if __has_extension(attribute_deprecated_with_message) -# define _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE 1 -# endif +# define _OSMO_HAS_ATTRIBUTE_DEPRECATED __has_attribute(deprecated) +# define _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE __has_extension(attribute_deprecated_with_message) #elif defined(__GNUC__) # define _OSMO_HAS_ATTRIBUTE_DEPRECATED 1 -# if OSMO_GNUC_PREREQ(4,5) -# define _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE 1 -# endif +# define _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE OSMO_GNUC_PREREQ(4,5) #endif -#if defined(_OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE) +#if _OSMO_HAS_ATTRIBUTE_DEPRECATED_WITH_MESSAGE # define OSMO_DEPRECATED(text) __attribute__((__deprecated__(text))) -#elif defined(_OSMO_HAS_ATTRIBUTE_DEPRECATED) +#elif _OSMO_HAS_ATTRIBUTE_DEPRECATED # define OSMO_DEPRECATED(text) __attribute__((__deprecated__)) #else # define OSMO_DEPRECATED(text) -- 1.7.9.5 From ml at bongiorni.eu Tue Aug 20 18:02:15 2013 From: ml at bongiorni.eu (Luca Bongiorni) Date: Tue, 20 Aug 2013 21:02:15 +0300 Subject: Hard reset NanoBTS after forgetting static IP Message-ID: <0B9AC9F7-BD29-4A62-8708-A99B7E79163C@bongiorni.eu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey there, I have come across a nanoBTS 165AU but since is used and not tested from the previous owner, I guess it has set a static IP. After turned on is booting (RED light) and then remains (ORANGE not flashing) even if the eth is connected to the router. At the moment I am trying with ipaccess-find and BtsInstaller to find in on my LAN . Unfortunately it is not answering and is not even getting an IP from the router by the DHCP daemon. Two possibilities, I have thought: - - an hw/sw issue; - - a Static IP is set. Supposing that is the 2nd possibility, I was thinking: - - to change private class of my LAN, to see if it changes something; - - to make an hard reset of the bts. Do you know if it possible to reset in someway? Ever happened this issue to you guys? Suggestions or insults are welcome. Thanks in advance. Cheers, Luca P.S.: I don't recall exactly, but one time I heard that is possible to reset by short-circuiting some pins of the LAN/48VDC eth connector. Is it right?! -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org iQIcBAEBAgAGBQJSE682AAoJEPLE1Qsi6ZiTuKkQAJaYGFTgMF5XlWuZuCI1eSvU lVCvpdB+fDRY7o6iut3y0fGlS1ZOIS8X93c7/T0XKUvSJaZ2ARIGjqi81A4XlkAK pdFvBNPKixYATYZYhP3nIggC1QGK9fuWQSUKVEGgnswsXt0VaJKdEwgn0CX7ttku uoh6FM3vtp30drB4t9oe0bW9M9qzGz6yyw+8asaqQBs8bafOHm4+S4kJsN6lYmPU wY/s8ctzqZerNI0MwBVASZCFldsyWe0NuduquYZlwg4god996srFNkVQL+o9nrmF vmPb896DTsCdivwqs+UyaZOgp1mKxjtfco275pVATG4qSAgz/JYQBxWK6fWQr+Zv PIzQvFLME1kh/29nUihxw93mzju5Rz1naTosx5+Fs7jPjCFocqD5Var3hkU4iu78 kNALJNx6UGOdfbqcInO30ltSm21HH1QBJnIoZf6MblELvHcvHbBNyPB8zM13suoS y3/oD/wcXefQaMaSa5HFc30ydJHBWS+adNlVp3fdYYArZaVkFxaVjJx8fW1juPVx 54aco5j7/tZD5tfg9FCOTHqmAiOVDqjs7nZrOpsRdkdPJHq2uHbGmHGqyhZlVWNv B+9/eiOdQyKZ5R+3vvRrmhBe9g2a28xtRI7N8KxwCov0wbA6R0h8l2UtGza6NTcn EUdW3ptIWP216tSFdVTs =9Ctc -----END PGP SIGNATURE----- From cr3 at cr3.us Tue Aug 20 18:40:13 2013 From: cr3 at cr3.us (Chris Rankine) Date: Tue, 20 Aug 2013 14:40:13 -0400 Subject: Hard reset NanoBTS after forgetting static IP In-Reply-To: <0B9AC9F7-BD29-4A62-8708-A99B7E79163C@bongiorni.eu> References: <0B9AC9F7-BD29-4A62-8708-A99B7E79163C@bongiorni.eu> Message-ID: Short out pins 9 and 10. Some folks who can get their hands on a 10-pin RJ45 plug can make a dongle to do it, however I just use a small flat head screwdriver and patience. A little more info here http://listarc.com/showthread.php?730101-Unable+to+configure+a+BTS On Tue, Aug 20, 2013 at 2:02 PM, Luca Bongiorni wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hey there, > I have come across a nanoBTS 165AU but since is used and not tested from > the previous owner, I guess it has set a static IP. > After turned on is booting (RED light) and then remains (ORANGE not > flashing) even if the eth is connected to the router. > > At the moment I am trying with ipaccess-find and BtsInstaller to find in > on my LAN . > Unfortunately it is not answering and is not even getting an IP from the > router by the DHCP daemon. > > Two possibilities, I have thought: > - - an hw/sw issue; > - - a Static IP is set. > > Supposing that is the 2nd possibility, I was thinking: > - - to change private class of my LAN, to see if it changes something; > - - to make an hard reset of the bts. > > Do you know if it possible to reset in someway? > Ever happened this issue to you guys? > Suggestions or insults are welcome. > > Thanks in advance. > Cheers, > Luca > > P.S.: I don't recall exactly, but one time I heard that is possible to > reset by short-circuiting some pins of the LAN/48VDC eth connector. Is it > right?! > -----BEGIN PGP SIGNATURE----- > Version: GnuPG/MacGPG2 v2.0.17 (Darwin) > Comment: GPGTools - http://gpgtools.org > > iQIcBAEBAgAGBQJSE682AAoJEPLE1Qsi6ZiTuKkQAJaYGFTgMF5XlWuZuCI1eSvU > lVCvpdB+fDRY7o6iut3y0fGlS1ZOIS8X93c7/T0XKUvSJaZ2ARIGjqi81A4XlkAK > pdFvBNPKixYATYZYhP3nIggC1QGK9fuWQSUKVEGgnswsXt0VaJKdEwgn0CX7ttku > uoh6FM3vtp30drB4t9oe0bW9M9qzGz6yyw+8asaqQBs8bafOHm4+S4kJsN6lYmPU > wY/s8ctzqZerNI0MwBVASZCFldsyWe0NuduquYZlwg4god996srFNkVQL+o9nrmF > vmPb896DTsCdivwqs+UyaZOgp1mKxjtfco275pVATG4qSAgz/JYQBxWK6fWQr+Zv > PIzQvFLME1kh/29nUihxw93mzju5Rz1naTosx5+Fs7jPjCFocqD5Var3hkU4iu78 > kNALJNx6UGOdfbqcInO30ltSm21HH1QBJnIoZf6MblELvHcvHbBNyPB8zM13suoS > y3/oD/wcXefQaMaSa5HFc30ydJHBWS+adNlVp3fdYYArZaVkFxaVjJx8fW1juPVx > 54aco5j7/tZD5tfg9FCOTHqmAiOVDqjs7nZrOpsRdkdPJHq2uHbGmHGqyhZlVWNv > B+9/eiOdQyKZ5R+3vvRrmhBe9g2a28xtRI7N8KxwCov0wbA6R0h8l2UtGza6NTcn > EUdW3ptIWP216tSFdVTs > =9Ctc > -----END PGP SIGNATURE----- > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas at eversberg.eu Tue Aug 20 18:48:28 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Tue, 20 Aug 2013 20:48:28 +0200 Subject: Hard reset NanoBTS after forgetting static IP In-Reply-To: <0B9AC9F7-BD29-4A62-8708-A99B7E79163C@bongiorni.eu> References: <0B9AC9F7-BD29-4A62-8708-A99B7E79163C@bongiorni.eu> Message-ID: <5213B9FC.5030601@eversberg.eu> Luca Bongiorni wrote: > Do you know if it possible to reset in someway? > > reset-procedure: In case you have a static-ip configured nanoBTS or other inconvenience with the nanoBTS ... just use the reset-dongle. The reset-dongle is a plug for the TIB-IN with short 9+10. The reset procedure is as follows: Power off Reset-dongle in TIB-IN Power on Wait until the light is flashing red (30 sec.) Power off When you are now starting the nanoBTS the light will flash red/green to tell you there is no ID set. Find the ip now by ipaccess-find eth0 Set the ID by ipaccess-config -u 1/0/0 999.999.999.999 The 999.999.999.999 is for the ip :-) From ml at bongiorni.eu Tue Aug 20 20:16:07 2013 From: ml at bongiorni.eu (Luca Bongiorni) Date: Tue, 20 Aug 2013 23:16:07 +0300 Subject: Hard reset NanoBTS after forgetting static IP In-Reply-To: <5213B9FC.5030601@eversberg.eu> References: <0B9AC9F7-BD29-4A62-8708-A99B7E79163C@bongiorni.eu> <5213B9FC.5030601@eversberg.eu> Message-ID: Hi, > reset-procedure: > > In case you have a static-ip configured nanoBTS or other inconvenience with > the nanoBTS ... just use the reset-dongle. > The reset-dongle is a plug for the TIB-IN with short 9+10. > The reset procedure is as follows: > Power off > Reset-dongle in TIB-IN > Power on > Wait until the light is flashing red (30 sec.) > Power off > When you are now starting the nanoBTS the light will flash red/green to tell > you there is no ID set. > Find the ip now by ipaccess-find eth0 > Set the ID by ipaccess-config -u 1/0/0 999.999.999.999 > The 999.999.999.999 is for the ip :-) As suggested by you and Chris, I have patiently shorted 9+10 and the light started to blink RED. Subsequently I have turned off the bts and removed the shortcircuit. However, after turning it on again, the situation is always on ORANGE stable/not blinking light. Right now I am reading the manual and it says: "LED_SELF_TEST, Orange Steady, From power on until end of backhaul power on self-test" I am wondering what else could be the problem. Maybe the MacGyver's way to short-circuit didn't work properly. (I am going to look for a proper RJ-69) I have also noticed that if I don't plug it into the router, the BTS shows a RED stable/not blinking light. And as the manual says, it could be a bad sign (I guess): "LED_SELF_TEST_FAILURE, Red Steady, In boot or application code when a power on self-test fails. LED_UNSPECIFIED_FAILURE, Red Steady, On s/w fatal errors." If you have other suggestions will be appreciated. Thanks. Cheers, Luca P.S. Just to be precise, I have followed the standard pin numeration to find the 9-10 pins ( http://quatech.com/products/images/rj45_sds.gif ) -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 881 bytes Desc: Questa ? un messaggio firmato elettronicamente URL: From ml at bongiorni.eu Wed Aug 21 19:34:45 2013 From: ml at bongiorni.eu (Luca Bongiorni) Date: Wed, 21 Aug 2013 22:34:45 +0300 Subject: Hard reset NanoBTS after forgetting static IP References: Message-ID: Hey there, I have tried for three hours to repeat again and again the hard reset and the procedure was fine (aka Red light blinking and then turning off the bts). But still, after the hard reset, the nanobts boots (red light) and then stays fixed on Orange. sad :( Obviously with my other rugby-139 both ipaccess-find and BTSInstaller work perfectly, so I strongly suppose that the problem should be more serious than a static IP issue. I have tried to delve into the manuals, but unfortunately, I didn't find nothing useful. Maybe a good soul can suggest me something else to try before giving up (e.g. UART, JTAG, USB connector?!). Thank you for the attention. Cheers, Luca > As suggested by you and Chris, I have patiently shorted 9+10 and the light started to blink RED. Subsequently I have turned off the bts and removed the shortcircuit. > However, after turning it on again, the situation is always on ORANGE stable/not blinking light. > > Right now I am reading the manual and it says: > "LED_SELF_TEST, Orange Steady, From power on until end of backhaul power on self-test" > > I am wondering what else could be the problem. Maybe the MacGyver's way to short-circuit didn't work properly. (I am going to look for a proper RJ-69) > > I have also noticed that if I don't plug it into the router, the BTS shows a RED stable/not blinking light. > And as the manual says, it could be a bad sign (I guess): > > "LED_SELF_TEST_FAILURE, Red Steady, In boot or application code when a power on self-test fails. > > LED_UNSPECIFIED_FAILURE, Red Steady, On s/w fatal errors." > > If you have other suggestions will be appreciated. Thanks. > > Cheers, > Luca > > P.S. Just to be precise, I have followed the standard pin numeration to find the 9-10 pins ( http://quatech.com/products/images/rj45_sds.gif ) -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 881 bytes Desc: Questa ? un messaggio firmato elettronicamente URL: From cr3 at cr3.us Wed Aug 21 20:14:42 2013 From: cr3 at cr3.us (Chris Rankine) Date: Wed, 21 Aug 2013 16:14:42 -0400 Subject: Hard reset NanoBTS after forgetting static IP In-Reply-To: References: Message-ID: Do you have a DHCP server on the local net to assign it a new IP address? Are you connecting to it via that IP address to set variables? On Wed, Aug 21, 2013 at 3:34 PM, Luca Bongiorni wrote: > Hey there, > I have tried for three hours to repeat again and again the hard reset and > the procedure was fine (aka Red light blinking and then turning off the > bts). > But still, after the hard reset, the nanobts boots (red light) and then > stays fixed on Orange. sad :( > > Obviously with my other rugby-139 both ipaccess-find and BTSInstaller work > perfectly, so I strongly suppose that the problem should be more serious > than a static IP issue. > I have tried to delve into the manuals, but unfortunately, I didn't find > nothing useful. > > Maybe a good soul can suggest me something else to try before giving up > (e.g. UART, JTAG, USB connector?!). > > Thank you for the attention. > Cheers, > Luca > > As suggested by you and Chris, I have patiently shorted 9+10 and the light > started to blink RED. Subsequently I have turned off the bts and removed > the shortcircuit. > However, after turning it on again, the situation is always on ORANGE > stable/not blinking light. > > Right now I am reading the manual and it says: > "LED_SELF_TEST, Orange Steady, From power on until end of backhaul power > on self-test" > > I am wondering what else could be the problem. Maybe the MacGyver's way to > short-circuit didn't work properly. (I am going to look for a proper RJ-69) > > I have also noticed that if I don't plug it into the router, the BTS shows > a RED stable/not blinking light. > And as the manual says, it could be a bad sign (I guess): > > "LED_SELF_TEST_FAILURE, Red Steady, In boot or application code when a > power on self-test fails. > > LED_UNSPECIFIED_FAILURE, Red Steady, On s/w fatal errors." > > If you have other suggestions will be appreciated. Thanks. > > Cheers, > Luca > > P.S. Just to be precise, I have followed the standard pin numeration to > find the 9-10 pins ( http://quatech.com/products/images/rj45_sds.gif ) > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mueller.lennart at googlemail.com Wed Aug 21 20:21:14 2013 From: mueller.lennart at googlemail.com (=?ISO-8859-1?Q?Lennart_M=FCller?=) Date: Wed, 21 Aug 2013 22:21:14 +0200 Subject: Hard reset NanoBTS after forgetting static IP In-Reply-To: <0B9AC9F7-BD29-4A62-8708-A99B7E79163C@bongiorni.eu> References: <0B9AC9F7-BD29-4A62-8708-A99B7E79163C@bongiorni.eu> Message-ID: 2013/8/20 Luca Bongiorni > Hey there, > I have come across a nanoBTS 165AU but since is used and not tested from > the previous owner, I guess it has set a static IP. > After turned on is booting (RED light) and then remains (ORANGE not > flashing) even if the eth is connected to the router. > How long have you been waiting? Mine needs about 2 minutes with steady yellow LED before switching to yellow flashing and connecting to BSC. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ml at bongiorni.eu Wed Aug 21 20:46:06 2013 From: ml at bongiorni.eu (Luca Bongiorni) Date: Wed, 21 Aug 2013 23:46:06 +0300 Subject: Hard reset NanoBTS after forgetting static IP In-Reply-To: References: <0B9AC9F7-BD29-4A62-8708-A99B7E79163C@bongiorni.eu> Message-ID: <4389D9AC-4D3F-4DF4-9BC2-9FA95AD84E06@bongiorni.eu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, >How long have you been waiting? Mine needs about 2 minutes with steady yellow LED before switching to yellow flashing and connecting to BSC. Well to be honest I didn't check precisely, but I guess around 4/5 minutes. I will try to keep it connected to the router and wait more. P.S. After short-circuiting the 9+10 and relative Red blinking, do you first turn off, subsequently remove the short and then turn it on again? Or do you remove the short while red light is blinking and then turn it off? I have tried both, just in case. > Do you have a DHCP server on the local net to assign it a new IP address? Are you connecting to it via that IP address to set variables? Actually the BTS is connected to the router, where is running the DHCP server. And I am pretty sure that this environment works, because the older rugby139 works perfectly with that. Cheers, Luca -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org iQIcBAEBAgAGBQJSFScUAAoJEPLE1Qsi6ZiTRhMQAMJZ3OrE6pwcrcwc2rhPB3Fi jyAYHfDQkAZcwBYkRGFFo+CfKEBPcEMo2voS8hhyV2m4vp+7R5KP/2BrSw7YV8V0 XfsV+1oYuj2SE+QpZsXGr2oKr1F+I8CbhIJz8Pk3QqZGK4PL3rqJUat37ajY4rN5 iJNDt8fhvWb5HSM+K3gDdYUQuY6v+SB/OQ34fZWMjBEosg+7MWcVoHc5eddHF2wg hxVSYHJibHQwpPPq3/xY9BqOBLlLEY0Cgo0r3S+Y5MMUryCRH+9rDC11aMQ3kqAY trx26ZFyIglh/KHTjx6qvohqIm/zr/5/4/M0wRhkYQlz2sXwKTqqcBTzPGGjdLMA MSKTq4Z77Xehoflqnv8N74YvbNiel1YegjGH+giO/PrOmw7R9+ZiEcOmGAlS/U+8 mhBGLLR1QnEpNVC37xeuDYhV+MyMk8VOVff8FYCWMsxATGe2w0F7uJVJt0homZqI 7aMYP4sLrz84/hZskRD6h2Ik3aUBDPo0Cxh4GN3ZuSFfcSx38dGU5RJy9wXrfuZ0 8NtnI9SeqKOKE+FsRLNjRPe+X77+qV2H/fG5uMLeH9TLpvwbKUxcnAyOljugAqf/ fpSYEayUWOQQgX5Ne2P6oBysMawLkbS80T+fz0EqUDVyGbSnT3vPZvg3RZZVEqej 0HTtoYH0Ckk2dfWuZfrQ =cpUD -----END PGP SIGNATURE----- From maicon.kist at inf.ufrgs.br Wed Aug 21 16:11:10 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Wed, 21 Aug 2013 13:11:10 -0300 Subject: OpenBSC + USRP Message-ID: Hi list, I'm trying to install the OpenBSC and made it work with a USRP N210 device. I'm having trouble installing the OsmoBTS (following this tutorial: http://openbsc.osmocom.org/trac/wiki/network_from_scratch). However, if I understood correctly, this tutorial is to use the with a UmTx device, right? Is there a tutorial to configure all the environment for a USRP device ? Btw, I having the following compile error when compiling the OsmoBTS with the --with-trx option: In file included from sysmobts_test.c:22:0: ../../src/osmo-bts-sysmo/femtobts.h:7:42: fatal error: sysmocom/femtobts/superfemto.h: No such file or directory Best Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From Ivan.Kluchnikov at fairwaves.ru Wed Aug 21 16:40:22 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Wed, 21 Aug 2013 20:40:22 +0400 Subject: OpenBSC + USRP In-Reply-To: References: Message-ID: Hi Maicon, Thank you for report, we will fix it soon. Use this simple fix: diff --git a/tests/Makefile.am b/tests/Makefile.am index d233df9..8a96e7e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = paging cipher sysmobts bursts handover +SUBDIRS = paging cipher bursts handover 2013/8/21 Maicon Kist : > Hi list, > > I'm trying to install the OpenBSC and made it work with a USRP N210 device. > I'm having trouble installing the OsmoBTS (following this tutorial: > http://openbsc.osmocom.org/trac/wiki/network_from_scratch). However, if I > understood correctly, this tutorial is to use the with a UmTx device, right? > > Is there a tutorial to configure all the environment for a USRP device ? > > > Btw, I having the following compile error when compiling the OsmoBTS with > the --with-trx option: > In file included from sysmobts_test.c:22:0: > ../../src/osmo-bts-sysmo/femtobts.h:7:42: fatal error: > sysmocom/femtobts/superfemto.h: No such file or directory > > > Best Regards, -- Regards, Ivan Kluchnikov. http://fairwaves.ru From andreas at eversberg.eu Wed Aug 21 16:52:33 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Wed, 21 Aug 2013 18:52:33 +0200 Subject: OpenBSC + USRP In-Reply-To: References: Message-ID: <5214F051.8070704@eversberg.eu> Maicon Kist wrote: > I'm trying to install the OpenBSC and made it work with a USRP N210 > device. I'm having trouble installing the OsmoBTS (following this > tutorial: http://openbsc.osmocom.org/trac/wiki/network_from_scratch). > However, if I understood correctly, this tutorial is to use the with a > UmTx device, right? > > Is there a tutorial to configure all the environment for a USRP device ? the doc is quick and incomplete. i never used an USRP, sorry. feel free to add it, as soon as you got it running. > Btw, I having the following compile error when compiling the OsmoBTS > with the --with-trx option: > In file included from sysmobts_test.c:22:0: > ../../src/osmo-bts-sysmo/femtobts.h:7:42: fatal error: > sysmocom/femtobts/superfemto.h: No such file or directory it seems that the test is always compiled, even without sysmo-bts support. try removing test from first line of tests/Makefile.am. regards, andreas -------------- next part -------------- An HTML attachment was scrubbed... URL: From mardnh at gmx.de Wed Aug 21 18:24:05 2013 From: mardnh at gmx.de (Martin Hauke) Date: Wed, 21 Aug 2013 20:24:05 +0200 Subject: OpenBSC + USRP In-Reply-To: <5214F051.8070704@eversberg.eu> References: <5214F051.8070704@eversberg.eu> Message-ID: <521505C5.6060503@gmx.de> Hi, i run into the same issue recently and made the following changes to fix the tests. best regards, Martin From mardnh at gmx.de Wed Aug 21 18:16:30 2013 From: mardnh at gmx.de (Martin Hauke) Date: Wed, 21 Aug 2013 20:16:30 +0200 Subject: [PATCH] fix tests for sysmobts Message-ID: --- tests/Makefile.am | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 5fb128f..4283a24 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,8 @@ -SUBDIRS = paging cipher sysmobts +SUBDIRS = paging cipher + +if ENABLE_SYSMOBTS +SUBDIRS += sysmobts +endif # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac -- 1.8.1.4 --------------080007040108030009010404 Content-Type: text/x-patch; name="0001-fix-tests-for-sysmobts-jolly-trx.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-fix-tests-for-sysmobts-jolly-trx.patch" From mardnh at gmx.de Wed Aug 21 18:18:40 2013 From: mardnh at gmx.de (Martin Hauke) Date: Wed, 21 Aug 2013 20:18:40 +0200 Subject: [PATCH] fix tests for sysmobts (jolly/trx) Message-ID: --- tests/Makefile.am | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index d233df9..e5f1e64 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,8 @@ -SUBDIRS = paging cipher sysmobts bursts handover +SUBDIRS = paging cipher bursts handover + +if ENABLE_SYSMOBTS +SUBDIRS += sysmobts +endif # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac -- 1.8.1.4 --------------080007040108030009010404-- From maiconkist at gmail.com Thu Aug 22 16:36:11 2013 From: maiconkist at gmail.com (Maicon Kist) Date: Thu, 22 Aug 2013 13:36:11 -0300 Subject: OpenBSC + USRP In-Reply-To: <521505C5.6060503@gmx.de> References: <5214F051.8070704@eversberg.eu> <521505C5.6060503@gmx.de> Message-ID: Hi list, thaks for you help. I manage to fix the problem by following the suggestion of Ivan Kluchnikov. Btw, run OpenBSC with a USRP is pretty easy: after the steps in the Running section (http://openbsc.osmocom.org/trac/wiki/network_from_scratch), I Started the transceiver app compiled within OpenBTS project (a binary compiled in the Transceiver52M directory) Thanks for all. abc On Wed, Aug 21, 2013 at 3:24 PM, Martin Hauke wrote: > Hi, > > i run into the same issue recently and made the following changes to fix > the tests. > > best regards, > Martin > -------------- next part -------------- An HTML attachment was scrubbed... URL: From boardsofcanada at live.co.uk Thu Aug 22 15:10:19 2013 From: boardsofcanada at live.co.uk (Adam B) Date: Thu, 22 Aug 2013 16:10:19 +0100 Subject: external app inserting an SMS in to sql table - how to? Message-ID: Hi Everyone. On the OpenBSC wiki it states: "Sending of SMS from external applications by writing to the SQL table"s .... I was wondering if anyone could fill me in how this happens and if the SMSC automatically sends the inserted SMS. Is it as simple as inserting in to the hlr.sqlite db as follows? INSERT INTO SMS (created, sender_id, receiver_id, reply_path_req, status_rep_req, protocol_id, data_coding_scheme, ud_hdr_ind, text) VALUES (date, 1, 123, 0, 0, 0, 0, 0, helloworld) My end goal would be to insert a the a binary data SMS that has UDH header in the data payload I was wondering if anyone has tried this and if it will work?. Regards Adam -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Thu Aug 22 18:13:07 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 22 Aug 2013 20:13:07 +0200 Subject: external app inserting an SMS in to sql table - how to? In-Reply-To: References: Message-ID: <20130822181307.GE14625@xiaoyu.lan> On Thu, Aug 22, 2013 at 04:10:19PM +0100, Adam B wrote: > Hi Everyone. Good Evening, > On the OpenBSC wiki it states: > "Sending of SMS from external applications by writing to the SQL table"s .... I was wondering if anyone could fill me in how this happens and if the SMSC automatically sends the inserted SMS. that is very bad advice, I have removed it from the wiki. In case you need to systematically send SMS, you should consider to use the SMPP interface. kind regards holger From maicon.kist at inf.ufrgs.br Thu Aug 22 17:40:00 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Thu, 22 Aug 2013 14:40:00 -0300 Subject: OpenBSC + USSD Application Message-ID: Hi list, Is there a tutorial in how to make a USSD application work in a OpenBSC network? Firstly I'm want to implement a simple "Hello World" application. eg. the client enter with a valid USSD number (*something) and the "Hello World" application executes. Best Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From maicon.kist at inf.ufrgs.br Fri Aug 23 21:26:00 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Fri, 23 Aug 2013 18:26:00 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: One more info: I tried to call the *#100# number to receive a USSD message with my phone number, but that didn't work. Intead, I received a message with a "Service Unavailable". Any hint? Thanks, On Thu, Aug 22, 2013 at 2:40 PM, Maicon Kist wrote: > Hi list, > > Is there a tutorial in how to make a USSD application work in a OpenBSC > network? > Firstly I'm want to implement a simple "Hello World" application. eg. the > client enter with a valid USSD number (*something) and the "Hello World" > application executes. > > > > Best Regards, > -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Sat Aug 24 13:46:57 2013 From: laforge at gnumonks.org (Harald Welte) Date: Sat, 24 Aug 2013 15:46:57 +0200 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: <20130824134657.GE16941@nataraja.gnumonks.org> On Fri, Aug 23, 2013 at 06:26:00PM -0300, Maicon Kist wrote: > I tried to call the *#100# number to receive a USSD message with my phone > number, but that didn't work. Intead, I received a message with a "Service > Unavailable". Any hint? you are either not connected to the OsmoNITB network, or there is some protocol incompatibility. Please use wireshark to trace the A-bis RSL communication between OsmoNITB and your BTS and have a look for the actual USSD request message as layer3 payload. Also, as usual, enabling the debug log level for the respective subsystems in OsmoNITB should give you some more information. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From alexander.chemeris at gmail.com Sat Aug 24 14:59:40 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Sat, 24 Aug 2013 18:59:40 +0400 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: On Thu, Aug 22, 2013 at 9:40 PM, Maicon Kist wrote: > Is there a tutorial in how to make a USSD application work in a OpenBSC > network? > Firstly I'm want to implement a simple "Hello World" application. eg. the > client enter with a valid USSD number (*something) and the "Hello World" > application executes. Look at the openbsc/src/libmsc/ussd.c file - it's very easy to extend it to respond to various USSD requests. It would be great if we have a kind of external API for implementing external USSD applications without touching the OsmoNITB code. Patches for this are welcome. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From maicon.kist at inf.ufrgs.br Sat Aug 24 19:46:11 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Sat, 24 Aug 2013 16:46:11 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: Hi Herald, I'm trying to check the log messages. I'm trying to understand whats happening, but so far nothing came to my mind. I'm attaching the osmo-nitb log messages right before I call the *#100# number. Do you have any suggestion? PS: SMS and calls are working perfectly. Best Regards, On Sat, Aug 24, 2013 at 11:59 AM, Alexander Chemeris < alexander.chemeris at gmail.com> wrote: > On Thu, Aug 22, 2013 at 9:40 PM, Maicon Kist > wrote: > > Is there a tutorial in how to make a USSD application work in a OpenBSC > > network? > > Firstly I'm want to implement a simple "Hello World" application. eg. the > > client enter with a valid USSD number (*something) and the "Hello World" > > application executes. > > Look at the openbsc/src/libmsc/ussd.c file - it's very easy to extend > it to respond to various USSD requests. It would be great if we have a > kind of external API for implementing external USSD applications > without touching the OsmoNITB code. Patches for this are welcome. > > -- > Regards, > Alexander Chemeris. > CEO, Fairwaves LLC / ??? ??????? > http://fairwaves.ru > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- <0004> abis_rsl.c:1438 (bts=0,trx=0,ts=0,ss=0) Activating ARFCN(869) SS(0) lctype SDCCH r=OTHER ra=0x13 ta=1 <0004> abis_rsl.c:1166 (bts=0,trx=0,ts=0,ss=0) CHANNEL ACTIVATE ACK <0000> abis_rsl.c:1628 (bts=0,trx=0,ts=0,ss=0) SAPI=0 ESTABLISH INDICATION <0002> gsm_04_08.c:910 <- CM SERVICE REQUEST serv_type=0x08 mi_type=0x04 M(1622723192) <0002> gsm_04_08.c:832 -> CM SERVICE ACK <0001> gsm_04_08.c:142 (bts 0 trx 0 ts 0 pd 05) Sending 0x21 to MS. <0000> abis_rsl.c:1628 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION <0003> bsc_api.c:498 CLASSMARK CHANGE CM2(len=3) CM3(len=5) <0000> abis_rsl.c:1628 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION <0002> ussd.c:58 USSD: Own number requested <0000> chan_alloc.c:406 (bts=0,trx=0,ts=0,ss=0) starting release sequence <0003> gsm_04_08_utils.c:231 Sending Channel Release: Chan: Number: 0 Type: 1 <0004> abis_rsl.c:634 (bts=0,trx=0,ts=0,ss=0) DEACTivate SACCH CMD <0004> abis_rsl.c:1070 (bts=0,trx=0,ts=0,ss=0): MEAS RES for inactive channel <0005> abis_nm.c:315 OC=SITE-MANAGER(00) INST=(ff,ff,ff) STATE CHG: OP_STATE=NULL AVAIL=Power off(02) <0005> abis_nm.c:315 OC=BTS(01) INST=(00,ff,ff) STATE CHG: OP_STATE=Enabled AVAIL=Dependency(05) <0005> abis_nm.c:1441 Set BTS Attr (bts=0) <0005> abis_nm.c:1755 OC=BTS(01) INST=(00,ff,ff) Sending OPSTART <0005> abis_nm.c:315 OC=GPRS-NSE(f0) INST=(00,ff,ff) STATE CHG: OP_STATE=NULL AVAIL=Dependency(05) <0005> abis_nm.c:315 OC=GPRS-CELL(f1) INST=(00,ff,ff) STATE CHG: OP_STATE=NULL AVAIL=Dependency(05) <0005> abis_nm.c:315 OC=GPRS-NSVC(f2) INST=(00,00,ff) STATE CHG: OP_STATE=NULL AVAIL=Dependency(05) <0005> abis_nm.c:315 OC=GPRS-NSVC(f2) INST=(00,01,ff) STATE CHG: OP_STATE=NULL AVAIL=Dependency(05) <0005> abis_nm.c:315 OC=RADIO-CARRIER(02) INST=(00,00,ff) STATE CHG: OP_STATE=Disabled AVAIL=OK(ff) <0005> abis_nm.c:1755 OC=RADIO-CARRIER(02) INST=(00,00,ff) Sending OPSTART <0005> abis_nm.c:315 OC=BASEBAND-TRANSCEIVER(04) INST=(00,00,ff) STATE CHG: OP_STATE=Disabled AVAIL=OK(ff) <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,00) STATE CHG: OP_STATE=Disabled AVAIL=Dependency(05) <0005> abis_nm.c:1644 Set Chan Attr (bts=0,trx=0,ts=0) <0005> abis_nm.c:1755 OC=CHANNEL(03) INST=(00,00,00) Sending OPSTART <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,01) STATE CHG: OP_STATE=Disabled AVAIL=Dependency(05) <0005> abis_nm.c:1644 Set Chan Attr (bts=0,trx=0,ts=1) <0005> abis_nm.c:1755 OC=CHANNEL(03) INST=(00,00,01) Sending OPSTART <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,02) STATE CHG: OP_STATE=Disabled AVAIL=Dependency(05) <0005> abis_nm.c:1644 Set Chan Attr (bts=0,trx=0,ts=2) <0005> abis_nm.c:1755 OC=CHANNEL(03) INST=(00,00,02) Sending OPSTART <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,03) STATE CHG: OP_STATE=Disabled AVAIL=Dependency(05) <0005> abis_nm.c:1644 Set Chan Attr (bts=0,trx=0,ts=3) <0005> abis_nm.c:1755 OC=CHANNEL(03) INST=(00,00,03) Sending OPSTART <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,04) STATE CHG: OP_STATE=Disabled AVAIL=Dependency(05) <0005> abis_nm.c:1644 Set Chan Attr (bts=0,trx=0,ts=4) <0005> abis_nm.c:1755 OC=CHANNEL(03) INST=(00,00,04) Sending OPSTART <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,05) STATE CHG: OP_STATE=Disabled AVAIL=Dependency(05) <0005> abis_nm.c:1644 Set Chan Attr (bts=0,trx=0,ts=5) <0005> abis_nm.c:1755 OC=CHANNEL(03) INST=(00,00,05) Sending OPSTART <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,06) STATE CHG: OP_STATE=Disabled AVAIL=Dependency(05) <0005> abis_nm.c:1644 Set Chan Attr (bts=0,trx=0,ts=6) <0005> abis_nm.c:1755 OC=CHANNEL(03) INST=(00,00,06) Sending OPSTART <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,07) STATE CHG: OP_STATE=Disabled AVAIL=Dependency(05) <0005> abis_nm.c:1644 Set Chan Attr (bts=0,trx=0,ts=7) <0005> abis_nm.c:1755 OC=CHANNEL(03) INST=(00,00,07) Sending OPSTART <0005> abis_nm.c:315 OC=RADIO-CARRIER(02) INST=(00,00,ff) Software Activated Report <0005> abis_nm.c:1458 Set TRX Attr (bts=0,trx=0) <0005> abis_nm.c:1755 OC=RADIO-CARRIER(02) INST=(00,00,ff) Sending OPSTART <0005> abis_nm.c:315 OC=BASEBAND-TRANSCEIVER(04) INST=(00,00,ff) Software Activated Report <0005> abis_nm.c:1755 OC=BASEBAND-TRANSCEIVER(04) INST=(00,00,ff) Sending OPSTART <0005> abis_nm.c:2574 ip.access RSL CONNECT IP=0.0.0.0 PORT=3003 STREAM=0x00 <0005> abis_nm.c:315 OC=RADIO-CARRIER(02) INST=(00,00,ff) STATE CHG: OP_STATE=Enabled AVAIL=OK(ff) <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,00) STATE CHG: OP_STATE=Enabled AVAIL=OK(ff) <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,01) STATE CHG: OP_STATE=Enabled AVAIL=OK(ff) <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,02) STATE CHG: OP_STATE=Enabled AVAIL=OK(ff) <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,03) STATE CHG: OP_STATE=Enabled AVAIL=OK(ff) <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,04) STATE CHG: OP_STATE=Enabled AVAIL=OK(ff) <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,05) STATE CHG: OP_STATE=Enabled AVAIL=OK(ff) <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,06) STATE CHG: OP_STATE=Enabled AVAIL=OK(ff) <0005> abis_nm.c:315 OC=CHANNEL(03) INST=(00,00,07) STATE CHG: OP_STATE=Enabled AVAIL=OK(ff) <0005> abis_nm.c:315 OC=BASEBAND-TRANSCEIVER(04) INST=(00,00,ff) STATE CHG: OP_STATE=Enabled AVAIL=OK(ff) <0005> abis_nm.c:2416 OC=BASEBAND-TRANSCEIVER(04) INST=(00,00,ff) IPACCESS(0xe1): RSL CONNECT ACK <0004> bsc_init.c:265 bootstrapping RSL for BTS/TRX (0/0) on ARFCN 869 using MCC=262 MNC=42 LAC=1 CID=0 BSIC=63 TSC=7 <0003> system_information.c:369 Serving cell: 869 <0003> bsc_init.c:103 SI1: 55 06 19 8f b2 80 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 04 00 2b <0003> bsc_init.c:103 SI2: 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00 <0003> bsc_init.c:103 SI3: 49 06 1b 00 00 62 f2 24 00 01 49 03 05 27 4f 40 e5 04 00 3b 2b 2b 2b <0003> bsc_init.c:103 SI4: 31 06 1c 62 f2 24 00 01 4f 40 e5 04 00 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b <0003> bsc_init.c:103 SI5: 49 06 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2b 2b 2b 2b <0003> bsc_init.c:103 SI6: 2d 06 1e 00 00 62 f2 24 00 01 27 ff 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b From alexander.chemeris at gmail.com Sat Aug 24 20:36:58 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Sun, 25 Aug 2013 00:36:58 +0400 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: Maicon, Your log doesn't show any user activity, so you either (1) haven't enabled enough logging or (2) your phone is not attached to the OsmoNITB network. If you followed instructions from http://openbsc.osmocom.org/trac/wiki/network_from_scratch, then you should have enough logging enabled. In this case we have only option (2) left and it would be great if you specify your software and hardware setup and describe the procedure you're using to select the network in your phone. On Sat, Aug 24, 2013 at 11:46 PM, Maicon Kist wrote: > Hi Herald, > > I'm trying to check the log messages. I'm trying to understand whats > happening, but so far nothing came to my mind. > I'm attaching the osmo-nitb log messages right before I call the *#100# > number. > > Do you have any suggestion? > > PS: SMS and calls are working perfectly. > > Best Regards, > > > On Sat, Aug 24, 2013 at 11:59 AM, Alexander Chemeris > wrote: >> >> On Thu, Aug 22, 2013 at 9:40 PM, Maicon Kist >> wrote: >> > Is there a tutorial in how to make a USSD application work in a OpenBSC >> > network? >> > Firstly I'm want to implement a simple "Hello World" application. eg. >> > the >> > client enter with a valid USSD number (*something) and the "Hello World" >> > application executes. >> >> Look at the openbsc/src/libmsc/ussd.c file - it's very easy to extend >> it to respond to various USSD requests. It would be great if we have a >> kind of external API for implementing external USSD applications >> without touching the OsmoNITB code. Patches for this are welcome. >> >> -- >> Regards, >> Alexander Chemeris. >> CEO, Fairwaves LLC / ??? ??????? >> http://fairwaves.ru > > -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From mueller.lennart at googlemail.com Sat Aug 24 20:51:07 2013 From: mueller.lennart at googlemail.com (=?ISO-8859-1?Q?Lennart_M=FCller?=) Date: Sat, 24 Aug 2013 22:51:07 +0200 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: 2013/8/24 Alexander Chemeris > Your log doesn't show any user activity, so you either (1) haven't > enabled enough logging or (2) your phone is not attached to the > OsmoNITB network. > <0004> abis_rsl.c:1438 (bts=0,trx=0,ts=0,ss=0) Activating ARFCN(869) SS(0) lctype SDCCH r=OTHER ra=0x13 ta=1 <0004> abis_rsl.c:1166 (bts=0,trx=0,ts=0,ss=0) CHANNEL ACTIVATE ACK <0000> abis_rsl.c:1628 (bts=0,trx=0,ts=0,ss=0) SAPI=0 ESTABLISH INDICATION <0002> gsm_04_08.c:910 <- CM SERVICE REQUEST serv_type=0x08 mi_type=0x04 M(1622723192) <0002> gsm_04_08.c:832 -> CM SERVICE ACK <0001> gsm_04_08.c:142 (bts 0 trx 0 ts 0 pd 05) Sending 0x21 to MS. <0000> abis_rsl.c:1628 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION <0003> bsc_api.c:498 CLASSMARK CHANGE CM2(len=3) CM3(len=5) <0000> abis_rsl.c:1628 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION <0002> ussd.c:58 USSD: Own number requested <0000> chan_alloc.c:406 (bts=0,trx=0,ts=0,ss=0) starting release sequence <0003> gsm_04_08_utils.c:231 Sending Channel Release: Chan: Number: 0 Type: 1 <0004> abis_rsl.c:634 (bts=0,trx=0,ts=0,ss=0) DEACTivate SACCH CMD I call that an USSD request. -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.chemeris at gmail.com Sun Aug 25 07:21:00 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Sun, 25 Aug 2013 11:21:00 +0400 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: On Sun, Aug 25, 2013 at 12:51 AM, Lennart M?ller wrote: > 2013/8/24 Alexander Chemeris >> >> Your log doesn't show any user activity, so you either (1) haven't >> enabled enough logging or (2) your phone is not attached to the >> OsmoNITB network. > > > <0004> abis_rsl.c:1438 (bts=0,trx=0,ts=0,ss=0) Activating ARFCN(869) SS(0) > lctype SDCCH r=OTHER ra=0x13 ta=1 > <0004> abis_rsl.c:1166 (bts=0,trx=0,ts=0,ss=0) CHANNEL ACTIVATE ACK > <0000> abis_rsl.c:1628 (bts=0,trx=0,ts=0,ss=0) SAPI=0 ESTABLISH INDICATION > <0002> gsm_04_08.c:910 <- CM SERVICE REQUEST serv_type=0x08 mi_type=0x04 > M(1622723192) > <0002> gsm_04_08.c:832 -> CM SERVICE ACK > <0001> gsm_04_08.c:142 (bts 0 trx 0 ts 0 pd 05) Sending 0x21 to MS. > <0000> abis_rsl.c:1628 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION > <0003> bsc_api.c:498 CLASSMARK CHANGE CM2(len=3) CM3(len=5) > <0000> abis_rsl.c:1628 (bts=0,trx=0,ts=0,ss=0) SAPI=0 DATA INDICATION > <0002> ussd.c:58 USSD: Own number requested > <0000> chan_alloc.c:406 (bts=0,trx=0,ts=0,ss=0) starting release sequence > <0003> gsm_04_08_utils.c:231 Sending Channel Release: Chan: Number: 0 Type: > 1 > <0004> abis_rsl.c:634 (bts=0,trx=0,ts=0,ss=0) DEACTivate SACCH CMD > > I call that an USSD request. Hum, indeed, this is a correct USSD request/response. Maicon wrote "log messages right before I call", so I was looking at the end of the log, which looks like a startup sequence of a BTS. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From maicon.kist at inf.ufrgs.br Sat Aug 24 20:53:56 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Sat, 24 Aug 2013 17:53:56 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: Hi Harald (sorry for the typo). I think that line 10 is a log of the USSD call I made. My configuration is: - Followed the tutorial. ( http://openbsc.osmocom.org/trac/wiki/network_from_scratch (using all configurations shown in the tutoria, except the network name, that I changed to DCG). - Using a Ettus USRP N210 - All libraries installed in my notebook, with Ubuntu 13.04 kernel 3.8.0-29-generic. - Starting osmo-nitb with the following command: osmo-nitb -c ~/.osmocom/open-bsc.cfg -l ~/.osmocom/hlr.sqlite3 -P -m -C --debug=DRLL:DCC:DMM:DRR:DRSL:DNM - I manually select the network in the Network Preferences. The phone is an old Motorola Z6. Hope it helps. If you need more information, just ask. If you need, I can use other configurations or command options. Best Regard, On Sat, Aug 24, 2013 at 5:37 PM, Alexander Chemeris < alexander.chemeris at gmail.com> wrote: > Of-list: His name is "Harald", not "Herald" :) > > On Sun, Aug 25, 2013 at 12:36 AM, Alexander Chemeris > wrote: > > Maicon, > > > > Your log doesn't show any user activity, so you either (1) haven't > > enabled enough logging or (2) your phone is not attached to the > > OsmoNITB network. > > > > If you followed instructions from > > http://openbsc.osmocom.org/trac/wiki/network_from_scratch, then you > > should have enough logging enabled. In this case we have only option > > (2) left and it would be great if you specify your software and > > hardware setup and describe the procedure you're using to select the > > network in your phone. > > > > On Sat, Aug 24, 2013 at 11:46 PM, Maicon Kist > wrote: > >> Hi Herald, > >> > >> I'm trying to check the log messages. I'm trying to understand whats > >> happening, but so far nothing came to my mind. > >> I'm attaching the osmo-nitb log messages right before I call the *#100# > >> number. > >> > >> Do you have any suggestion? > >> > >> PS: SMS and calls are working perfectly. > >> > >> Best Regards, > >> > >> > >> On Sat, Aug 24, 2013 at 11:59 AM, Alexander Chemeris > >> wrote: > >>> > >>> On Thu, Aug 22, 2013 at 9:40 PM, Maicon Kist > > >>> wrote: > >>> > Is there a tutorial in how to make a USSD application work in a > OpenBSC > >>> > network? > >>> > Firstly I'm want to implement a simple "Hello World" application. eg. > >>> > the > >>> > client enter with a valid USSD number (*something) and the "Hello > World" > >>> > application executes. > >>> > >>> Look at the openbsc/src/libmsc/ussd.c file - it's very easy to extend > >>> it to respond to various USSD requests. It would be great if we have a > >>> kind of external API for implementing external USSD applications > >>> without touching the OsmoNITB code. Patches for this are welcome. > >>> > >>> -- > >>> Regards, > >>> Alexander Chemeris. > >>> CEO, Fairwaves LLC / ??? ??????? > >>> http://fairwaves.ru > >> > >> > > > > > > > > -- > > Regards, > > Alexander Chemeris. > > CEO, Fairwaves LLC / ??? ??????? > > http://fairwaves.ru > > > > -- > Regards, > Alexander Chemeris. > CEO, Fairwaves LLC / ??? ??????? > http://fairwaves.ru > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.chemeris at gmail.com Sun Aug 25 07:50:16 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Sun, 25 Aug 2013 11:50:16 +0400 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: 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 From maiconkist at gmail.com Sun Aug 25 19:11:24 2013 From: maiconkist at gmail.com (Maicon Kist) Date: Sun, 25 Aug 2013 16:11:24 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: Hi Alexander, I didn't even notice that the BTS restarts (it wasn't me). I will send the capture tomorrow. Thank for all help. Best Regards, abc 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 maicon.kist at inf.ufrgs.br Mon Aug 26 10:51:33 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Mon, 26 Aug 2013 07:51:33 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: 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 maicon.kist at inf.ufrgs.br Mon Aug 26 17:16:01 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Mon, 26 Aug 2013 14:16:01 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: 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: -------------- next part -------------- A non-text attachment was scrubbed... Name: openbsc.pcap Type: application/octet-stream Size: 115192 bytes Desc: not available URL: From maicon.kist at inf.ufrgs.br Sat Aug 31 14:25:52 2013 From: maicon.kist at inf.ufrgs.br (Maicon Kist) Date: Sat, 31 Aug 2013 11:25:52 -0300 Subject: OpenBSC + USSD Application In-Reply-To: References: Message-ID: 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 dmi3sol at gmail.com Sun Aug 25 10:51:12 2013 From: dmi3sol at gmail.com (Dmitri Soloviev) Date: Sun, 25 Aug 2013 14:51:12 +0400 Subject: OpenBSC with A-interface Message-ID: Hi list, Peter, thank you for your reply. I still have questions about media control: 1) when parsing MGCP CRCX, sdp is not expected. May I change it? 2) I still can't run media in BSC mode. Seems I'm missing something. osmo-bsc and osmo-bsc_mgcp are running BSSAP works perfectly But it seems two interfaces are working completely independent: -- MGCP between MSC and BSC -- interface between BSC and BTS (ip.access): at MGCP, connection is acknowledged, endpoint is allocated (at BSC ip=192.168.1.11) at ip.access interface between BSC and BTS, BTS replies to ip.accessCRCX with proper acknowledgement with proper ip:port at BTS (192.168.1.9) , then BSC issues ip.accessMDCX with endpoint ip zero: 7e:73:01:09:f8:00:2d:*f0:00:00:00:00*:f1:0f:be:f4:00:f2:03 My attempts to modify connection at MGCP interface has no impact on ip.access interface The key question, I'm not getting how osmo-bsc and osmo0bsc_mgcp are interacting. Thank you, Dmitri PS my configs are mgcp local ip 192.168.1.11 bts ip 192.168.1.9 bind ip 192.168.1.11 bind port 2427 rtp base 6000 sdp audio payload number 3 sdp audio payload name GSM/8000 number endpoints 31 and e1_input e1_line 0 driver ipa network network country code 250 mobile network code 07 short name OsmoBSC long name OsmoBSC auth policy closed location updating reject cause 13 ! encryption a5 1 neci 1 paging any use tch 0 rrlp mode none mm info 1 handover 0 handover window rxlev averaging 10 handover window rxqual averaging 1 handover window rxlev neighbor averaging 10 handover power budget interval 6 handover power budget hysteresis 3 handover maximum distance 9999 timer t3101 10 timer t3103 0 timer t3105 0 timer t3107 0 timer t3109 0 timer t3111 0 timer t3113 60 timer t3115 0 timer t3117 0 timer t3119 0 timer t3122 0 timer t3141 0 dtx-used 0 subscriber-keep-in-ram 0 bts 0 type nanobts band PCS1900 cell_identity 2611 location_area_code 51601 training_sequence_code 7 base_station_id_code 63 ms max power 15 cell reselection hysteresis 4 rxlev access min 0 channel allocator ascending rach tx integer 9 rach max transmission 7 ip.access unit_id 1801 0 oml ip.access stream_id 255 line 0 neighbor-list mode manual-si5 gprs mode none trx 0 rf_locked 0 arfcn 810 nominal power 0 max_power_red 20 rsl e1 tei 0 timeslot 0 phys_chan_config CCCH+SDCCH4 hopping enabled 0 timeslot 1 phys_chan_config TCH/F hopping enabled 0 timeslot 2 phys_chan_config TCH/F hopping enabled 0 timeslot 3 phys_chan_config TCH/F hopping enabled 0 timeslot 4 phys_chan_config TCH/F hopping enabled 0 timeslot 5 phys_chan_config TCH/F hopping enabled 0 timeslot 6 phys_chan_config TCH/F hopping enabled 0 timeslot 7 phys_chan_config TCH/F hopping enabled 0 msc ! ip.access rtp-base 6000 timeout-ping 20 timeout-pong 5 dest 192.168.50.10 5000 0 in fact, BSSAP goes from a card over VPN, while MGCP comes from self-written TRAU running locally, the same host as BSC -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Sun Aug 25 12:02:53 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sun, 25 Aug 2013 14:02:53 +0200 Subject: OpenBSC with A-interface In-Reply-To: References: Message-ID: <20130825120253.GV27820@xiaoyu.lan> On Sun, Aug 25, 2013 at 02:51:12PM +0400, Dmitri Soloviev wrote: > Hi list, > > But it seems two interfaces are working completely independent: yes, they just share one secret on how to go from endpoint number to rtp port. holger From dmi3sol at gmail.com Sun Aug 25 15:03:40 2013 From: dmi3sol at gmail.com (Dmitri Soloviev) Date: Sun, 25 Aug 2013 19:03:40 +0400 Subject: OpenBSC with A-interface In-Reply-To: <20130825120253.GV27820@xiaoyu.lan> References: <20130825120253.GV27820@xiaoyu.lan> Message-ID: 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? - 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? On Sun, Aug 25, 2013 at 4:02 PM, Holger Hans Peter Freyther < holger at freyther.de> wrote: > On Sun, Aug 25, 2013 at 02:51:12PM +0400, Dmitri Soloviev wrote: > > Hi list, > > > > But it seems two interfaces are working completely independent: > > yes, they just share one secret on how to go from endpoint number > to rtp port. > > > holger > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerlbeck at sysmocom.de Tue Aug 27 14:52:29 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Tue, 27 Aug 2013 16:52:29 +0200 Subject: [PATCH 1/2] bsc/ussd: Optionally send USSD message on MSC disconnection Message-ID: <1377615150-23065-1-git-send-email-jerlbeck@sysmocom.de> Send an USSD message on each MS connection if the connection to the MSC has been lost. Add a vty config command 'bsc-msc-loss-txt' in 'config-msc' to set the notification string and to enable the feature. Ticket: OW#957 --- openbsc/include/openbsc/osmo_msc_data.h | 3 +++ openbsc/src/osmo-bsc/osmo_bsc_sccp.c | 30 ++++++++++++++++++++++---- openbsc/src/osmo-bsc/osmo_bsc_vty.c | 36 +++++++++++++++++++++++++++++++ openbsc/tests/vty_test_runner.py | 34 +++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 4 deletions(-) diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/osmo_msc_data.h index ba93a08..86b4a84 100644 --- a/openbsc/include/openbsc/osmo_msc_data.h +++ b/openbsc/include/openbsc/osmo_msc_data.h @@ -83,6 +83,9 @@ struct osmo_msc_data { struct osmo_wqueue mgcp_agent; int nr; + + /* ussd msc connection lost text */ + char *ussd_msc_lost_txt; }; /* diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c index 3533d6d..ad554e8 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c @@ -262,13 +262,35 @@ int bsc_delete_connection(struct osmo_bsc_sccp_con *sccp) return 0; } -static void bsc_close_connections(struct bsc_msc_connection *msc_con) +static void bsc_notify_msc_lost(struct osmo_bsc_sccp_con *con) +{ + struct gsm_subscriber_connection *conn = con->conn; + + /* send USSD notification if string configured and con->data is set */ + if (!conn) + return; + + /* check for config string */ + if (!con->msc->ussd_msc_lost_txt) + return; + if (con->msc->ussd_msc_lost_txt[0] == '\0') + return; + + /* send USSD notification */ + gsm0480_send_ussdNotify(conn, 1, conn->sccp_con->msc->ussd_welcome_txt); + gsm0480_send_releaseComplete(conn); +} + +static void bsc_notify_and_close_conns(struct bsc_msc_connection *msc_con) { struct osmo_bsc_sccp_con *con, *tmp; llist_for_each_entry_safe(con, tmp, &active_connections, entry) { - if (con->msc->msc_con == msc_con) - bsc_sccp_force_free(con); + if (con->msc->msc_con != msc_con) + continue; + + bsc_notify_msc_lost(con); + bsc_sccp_force_free(con); } } @@ -282,7 +304,7 @@ static int handle_msc_signal(unsigned int subsys, unsigned int signal, msc = signal_data; if (signal == S_MSC_LOST) - bsc_close_connections(msc->data->msc_con); + bsc_notify_and_close_conns(msc->data->msc_con); return 0; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 49ae665..b715101 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -114,6 +114,11 @@ static void write_msc(struct vty *vty, struct osmo_msc_data *msc) if (msc->ussd_welcome_txt) vty_out(vty, " bsc-welcome-text %s%s", msc->ussd_welcome_txt, VTY_NEWLINE); + if (msc->ussd_msc_lost_txt && msc->ussd_msc_lost_txt[0]) + vty_out(vty, " bsc-msc-lost-text %s%s", msc->ussd_msc_lost_txt, VTY_NEWLINE); + else + vty_out(vty, " no bsc-msc-lost-text%s", VTY_NEWLINE); + if (msc->audio_length != 0) { int i; @@ -368,6 +373,35 @@ DEFUN(cfg_net_msc_welcome_ussd, return CMD_SUCCESS; } +DEFUN(cfg_net_msc_lost_ussd, + cfg_net_msc_lost_ussd_cmd, + "bsc-msc-lost-text .TEXT", + "Set the USSD notification to be sent on MSC connection loss\n" "Text to be sent\n") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + char *str = argv_concat(argv, argc, 0); + if (!str) + return CMD_WARNING; + + bsc_replace_string(osmo_bsc_data(vty), &data->ussd_msc_lost_txt, str); + talloc_free(str); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_msc_no_lost_ussd, + cfg_net_msc_no_lost_ussd_cmd, + "no bsc-msc-lost-text", + NO_STR "Clear the USSD notification to be sent on MSC connection loss\n") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + + if (data->ussd_msc_lost_txt) { + talloc_free(data->ussd_msc_lost_txt); + data->ussd_msc_lost_txt = 0; + } + return CMD_SUCCESS; +} + DEFUN(cfg_net_msc_type, cfg_net_msc_type_cmd, "type (normal|local)", @@ -579,6 +613,8 @@ int bsc_vty_init_extra(void) install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd); install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd); install_element(MSC_NODE, &cfg_net_msc_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_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 a7a7b3f..1285474 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -88,6 +88,39 @@ class TestVTYNITB(TestVTYBase): self.assertEquals(res.find('periodic location update 60'), -1) self.assert_(res.find('no periodic location update') > 0) +class TestVTYBSC(TestVTYBase): + + def vty_command(self): + return ["./src/osmo-bsc/osmo-bsc", "-c", + "doc/examples/osmo-bsc/osmo-bsc.cfg"] + + def vty_app(self): + return (4242, "./src/osmo-bsc/osmo-bsc", "OsmoBSC", "bsc") + + def testUssdNotifications(self): + self.vty.enable() + self.vty.command("configure terminal") + self.vty.command("msc") + + # Test invalid input + self.vty.verify("bsc-msc-lost-text", ['% Command incomplete.']) + + # Enable USSD notifications + self.vty.verify("bsc-msc-lost-text MSC disconnected", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('bsc-msc-lost-text MSC disconnected') > 0) + self.assertEquals(res.find('no bsc-msc-lost-text'), -1) + + # Now disable it.. + self.vty.verify("no bsc-msc-lost-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) + class TestVTYNAT(TestVTYBase): def vty_command(self): @@ -219,6 +252,7 @@ if __name__ == '__main__': print "Running tests for specific VTY commands" suite = unittest.TestSuite() suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYNITB)) + suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYBSC)) add_nat_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 Tue Aug 27 14:52:30 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Tue, 27 Aug 2013 16:52:30 +0200 Subject: [PATCH 2/2] bsc/vty: Add 'no bsc-welcome-text' command In-Reply-To: <1377615150-23065-1-git-send-email-jerlbeck@sysmocom.de> References: <1377615150-23065-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1377615150-23065-2-git-send-email-jerlbeck@sysmocom.de> There was no command to reset a bsc-welcome-text string, so it has been added. --- openbsc/src/osmo-bsc/osmo_bsc_vty.c | 20 +++++++++++++++++++- openbsc/tests/vty_test_runner.py | 7 +++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index b715101..d494353 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -111,8 +111,11 @@ static void write_msc(struct vty *vty, struct osmo_msc_data *msc) vty_out(vty, " ip.access rtp-base %d%s", msc->rtp_base, VTY_NEWLINE); vty_out(vty, " timeout-ping %d%s", msc->ping_timeout, VTY_NEWLINE); vty_out(vty, " timeout-pong %d%s", msc->pong_timeout, VTY_NEWLINE); + if (msc->ussd_welcome_txt) vty_out(vty, " bsc-welcome-text %s%s", msc->ussd_welcome_txt, VTY_NEWLINE); + else + vty_out(vty, " no bsc-welcome-text%s", VTY_NEWLINE); if (msc->ussd_msc_lost_txt && msc->ussd_msc_lost_txt[0]) vty_out(vty, " bsc-msc-lost-text %s%s", msc->ussd_msc_lost_txt, VTY_NEWLINE); @@ -361,7 +364,7 @@ DEFUN(cfg_net_msc_pong_time, DEFUN(cfg_net_msc_welcome_ussd, cfg_net_msc_welcome_ussd_cmd, "bsc-welcome-text .TEXT", - "Set the USSD notification to be sent.\n" "Text to be sent\n") + "Set the USSD notification to be sent\n" "Text to be sent\n") { struct osmo_msc_data *data = osmo_msc_data(vty); char *str = argv_concat(argv, argc, 0); @@ -373,6 +376,20 @@ DEFUN(cfg_net_msc_welcome_ussd, return CMD_SUCCESS; } +DEFUN(cfg_net_msc_no_welcome_ussd, + cfg_net_msc_no_welcome_ussd_cmd, + "no bsc-welcome-text", + NO_STR "Clear the USSD notification to be sent\n") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + + if (data->ussd_welcome_txt) { + talloc_free(data->ussd_welcome_txt); + data->ussd_welcome_txt = 0; + } + return CMD_SUCCESS; +} + DEFUN(cfg_net_msc_lost_ussd, cfg_net_msc_lost_ussd_cmd, "bsc-msc-lost-text .TEXT", @@ -613,6 +630,7 @@ int bsc_vty_init_extra(void) install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd); install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd); install_element(MSC_NODE, &cfg_net_msc_welcome_ussd_cmd); + 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_type_cmd); diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 1285474..faead54 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -104,22 +104,29 @@ class TestVTYBSC(TestVTYBase): # Test invalid input self.vty.verify("bsc-msc-lost-text", ['% Command incomplete.']) + self.vty.verify("bsc-welcome-text", ['% Command incomplete.']) # Enable USSD notifications self.vty.verify("bsc-msc-lost-text MSC disconnected", ['']) + self.vty.verify("bsc-welcome-text Hello MS", ['']) # Verify settings res = self.vty.command("write terminal") self.assert_(res.find('bsc-msc-lost-text MSC disconnected') > 0) 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) # Now disable it.. self.vty.verify("no bsc-msc-lost-text", ['']) + self.vty.verify("no bsc-welcome-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) class TestVTYNAT(TestVTYBase): -- 1.7.9.5 From holger at freyther.de Wed Aug 28 07:12:01 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 28 Aug 2013 09:12:01 +0200 Subject: [PATCH 2/2] bsc/vty: Add 'no bsc-welcome-text' command In-Reply-To: <1377615150-23065-2-git-send-email-jerlbeck@sysmocom.de> References: <1377615150-23065-1-git-send-email-jerlbeck@sysmocom.de> <1377615150-23065-2-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130828071201.GB1561@xiaoyu.lan> On Tue, Aug 27, 2013 at 04:52:30PM +0200, Jacob Erlbeck wrote: > if (msc->ussd_welcome_txt) > vty_out(vty, " bsc-welcome-text %s%s", msc->ussd_welcome_txt, VTY_NEWLINE); > + else > + vty_out(vty, " no bsc-welcome-text%s", VTY_NEWLINE); okay, we are in-conistent today about writing out defaults or not. > + if (data->ussd_welcome_txt) { > + talloc_free(data->ussd_welcome_txt); > + data->ussd_welcome_txt = 0; > + } we can skip the conditionals here as well. holger From holger at freyther.de Wed Aug 28 07:11:01 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 28 Aug 2013 09:11:01 +0200 Subject: [PATCH 1/2] bsc/ussd: Optionally send USSD message on MSC disconnection In-Reply-To: <1377615150-23065-1-git-send-email-jerlbeck@sysmocom.de> References: <1377615150-23065-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130828071101.GA1561@xiaoyu.lan> On Tue, Aug 27, 2013 at 04:52:29PM +0200, Jacob Erlbeck wrote: Hi, looks good! some small details. > + if (data->ussd_msc_lost_txt) { > + talloc_free(data->ussd_msc_lost_txt); > + data->ussd_msc_lost_txt = 0; > + } you can avoid the branches. talloc_free(NULL) is well defined. > + suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYBSC)) > add_nat_test(suite, workdir) the bsc is built conditionally, we will need to do something like it is done in add_nat_test. holger PS: I found an easy way to manually test your changes From jerlbeck at sysmocom.de Wed Aug 28 08:16:54 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 28 Aug 2013 10:16:54 +0200 Subject: [PATCH 1/2] bsc/ussd: Optionally send USSD message on MSC disconnection In-Reply-To: <1377615150-23065-1-git-send-email-jerlbeck@sysmocom.de> References: <1377615150-23065-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1377677815-27137-1-git-send-email-jerlbeck@sysmocom.de> Send an USSD message on each MS connection if the connection to the MSC has been lost. Add a vty config command 'bsc-msc-loss-txt' in 'config-msc' to set the notification string and to enable the feature. Ticket: OW#957 --- openbsc/include/openbsc/osmo_msc_data.h | 3 +++ openbsc/src/osmo-bsc/osmo_bsc_sccp.c | 30 +++++++++++++++++++--- openbsc/src/osmo-bsc/osmo_bsc_vty.c | 35 ++++++++++++++++++++++++++ openbsc/tests/vty_test_runner.py | 41 +++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 4 deletions(-) diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/osmo_msc_data.h index ba93a08..86b4a84 100644 --- a/openbsc/include/openbsc/osmo_msc_data.h +++ b/openbsc/include/openbsc/osmo_msc_data.h @@ -83,6 +83,9 @@ struct osmo_msc_data { struct osmo_wqueue mgcp_agent; int nr; + + /* ussd msc connection lost text */ + char *ussd_msc_lost_txt; }; /* diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c index 3533d6d..ad554e8 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c @@ -262,13 +262,35 @@ int bsc_delete_connection(struct osmo_bsc_sccp_con *sccp) return 0; } -static void bsc_close_connections(struct bsc_msc_connection *msc_con) +static void bsc_notify_msc_lost(struct osmo_bsc_sccp_con *con) +{ + struct gsm_subscriber_connection *conn = con->conn; + + /* send USSD notification if string configured and con->data is set */ + if (!conn) + return; + + /* check for config string */ + if (!con->msc->ussd_msc_lost_txt) + return; + if (con->msc->ussd_msc_lost_txt[0] == '\0') + return; + + /* send USSD notification */ + gsm0480_send_ussdNotify(conn, 1, conn->sccp_con->msc->ussd_welcome_txt); + gsm0480_send_releaseComplete(conn); +} + +static void bsc_notify_and_close_conns(struct bsc_msc_connection *msc_con) { struct osmo_bsc_sccp_con *con, *tmp; llist_for_each_entry_safe(con, tmp, &active_connections, entry) { - if (con->msc->msc_con == msc_con) - bsc_sccp_force_free(con); + if (con->msc->msc_con != msc_con) + continue; + + bsc_notify_msc_lost(con); + bsc_sccp_force_free(con); } } @@ -282,7 +304,7 @@ static int handle_msc_signal(unsigned int subsys, unsigned int signal, msc = signal_data; if (signal == S_MSC_LOST) - bsc_close_connections(msc->data->msc_con); + bsc_notify_and_close_conns(msc->data->msc_con); return 0; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 49ae665..501d9f5 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -114,6 +114,11 @@ static void write_msc(struct vty *vty, struct osmo_msc_data *msc) if (msc->ussd_welcome_txt) vty_out(vty, " bsc-welcome-text %s%s", msc->ussd_welcome_txt, VTY_NEWLINE); + if (msc->ussd_msc_lost_txt && msc->ussd_msc_lost_txt[0]) + vty_out(vty, " bsc-msc-lost-text %s%s", msc->ussd_msc_lost_txt, VTY_NEWLINE); + else + vty_out(vty, " no bsc-msc-lost-text%s", VTY_NEWLINE); + if (msc->audio_length != 0) { int i; @@ -368,6 +373,34 @@ DEFUN(cfg_net_msc_welcome_ussd, return CMD_SUCCESS; } +DEFUN(cfg_net_msc_lost_ussd, + cfg_net_msc_lost_ussd_cmd, + "bsc-msc-lost-text .TEXT", + "Set the USSD notification to be sent on MSC connection loss\n" "Text to be sent\n") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + char *str = argv_concat(argv, argc, 0); + if (!str) + return CMD_WARNING; + + bsc_replace_string(osmo_bsc_data(vty), &data->ussd_msc_lost_txt, str); + talloc_free(str); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_msc_no_lost_ussd, + cfg_net_msc_no_lost_ussd_cmd, + "no bsc-msc-lost-text", + NO_STR "Clear the USSD notification to be sent on MSC connection loss\n") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + + talloc_free(data->ussd_msc_lost_txt); + data->ussd_msc_lost_txt = 0; + + return CMD_SUCCESS; +} + DEFUN(cfg_net_msc_type, cfg_net_msc_type_cmd, "type (normal|local)", @@ -579,6 +612,8 @@ int bsc_vty_init_extra(void) install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd); install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd); install_element(MSC_NODE, &cfg_net_msc_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_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 a7a7b3f..fd200c8 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -88,6 +88,39 @@ class TestVTYNITB(TestVTYBase): self.assertEquals(res.find('periodic location update 60'), -1) self.assert_(res.find('no periodic location update') > 0) +class TestVTYBSC(TestVTYBase): + + def vty_command(self): + return ["./src/osmo-bsc/osmo-bsc", "-c", + "doc/examples/osmo-bsc/osmo-bsc.cfg"] + + def vty_app(self): + return (4242, "./src/osmo-bsc/osmo-bsc", "OsmoBSC", "bsc") + + def testUssdNotifications(self): + self.vty.enable() + self.vty.command("configure terminal") + self.vty.command("msc") + + # Test invalid input + self.vty.verify("bsc-msc-lost-text", ['% Command incomplete.']) + + # Enable USSD notifications + self.vty.verify("bsc-msc-lost-text MSC disconnected", ['']) + + # Verify settings + res = self.vty.command("write terminal") + self.assert_(res.find('bsc-msc-lost-text MSC disconnected') > 0) + self.assertEquals(res.find('no bsc-msc-lost-text'), -1) + + # Now disable it.. + self.vty.verify("no bsc-msc-lost-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) + class TestVTYNAT(TestVTYBase): def vty_command(self): @@ -189,6 +222,13 @@ def add_nat_test(suite, workdir): test = unittest.TestLoader().loadTestsFromTestCase(TestVTYNAT) suite.addTest(test) +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(TestVTYBSC) + suite.addTest(test) + if __name__ == '__main__': import argparse import sys @@ -219,6 +259,7 @@ if __name__ == '__main__': print "Running tests for specific VTY commands" suite = unittest.TestSuite() suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYNITB)) + add_bsc_test(suite, workdir) add_nat_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 Wed Aug 28 08:16:55 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Wed, 28 Aug 2013 10:16:55 +0200 Subject: [PATCH 2/2] bsc/vty: Add 'no bsc-welcome-text' command In-Reply-To: <1377677815-27137-1-git-send-email-jerlbeck@sysmocom.de> References: <1377615150-23065-1-git-send-email-jerlbeck@sysmocom.de> <1377677815-27137-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1377677815-27137-2-git-send-email-jerlbeck@sysmocom.de> There was no command to reset a bsc-welcome-text string, so it has been added. --- openbsc/src/osmo-bsc/osmo_bsc_vty.c | 19 ++++++++++++++++++- openbsc/tests/vty_test_runner.py | 7 +++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 501d9f5..8eaa55b 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -111,8 +111,11 @@ static void write_msc(struct vty *vty, struct osmo_msc_data *msc) vty_out(vty, " ip.access rtp-base %d%s", msc->rtp_base, VTY_NEWLINE); vty_out(vty, " timeout-ping %d%s", msc->ping_timeout, VTY_NEWLINE); vty_out(vty, " timeout-pong %d%s", msc->pong_timeout, VTY_NEWLINE); + if (msc->ussd_welcome_txt) vty_out(vty, " bsc-welcome-text %s%s", msc->ussd_welcome_txt, VTY_NEWLINE); + else + vty_out(vty, " no bsc-welcome-text%s", VTY_NEWLINE); if (msc->ussd_msc_lost_txt && msc->ussd_msc_lost_txt[0]) vty_out(vty, " bsc-msc-lost-text %s%s", msc->ussd_msc_lost_txt, VTY_NEWLINE); @@ -361,7 +364,7 @@ DEFUN(cfg_net_msc_pong_time, DEFUN(cfg_net_msc_welcome_ussd, cfg_net_msc_welcome_ussd_cmd, "bsc-welcome-text .TEXT", - "Set the USSD notification to be sent.\n" "Text to be sent\n") + "Set the USSD notification to be sent\n" "Text to be sent\n") { struct osmo_msc_data *data = osmo_msc_data(vty); char *str = argv_concat(argv, argc, 0); @@ -373,6 +376,19 @@ DEFUN(cfg_net_msc_welcome_ussd, return CMD_SUCCESS; } +DEFUN(cfg_net_msc_no_welcome_ussd, + cfg_net_msc_no_welcome_ussd_cmd, + "no bsc-welcome-text", + NO_STR "Clear the USSD notification to be sent\n") +{ + struct osmo_msc_data *data = osmo_msc_data(vty); + + talloc_free(data->ussd_welcome_txt); + data->ussd_welcome_txt = 0; + + return CMD_SUCCESS; +} + DEFUN(cfg_net_msc_lost_ussd, cfg_net_msc_lost_ussd_cmd, "bsc-msc-lost-text .TEXT", @@ -612,6 +628,7 @@ int bsc_vty_init_extra(void) install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd); install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd); install_element(MSC_NODE, &cfg_net_msc_welcome_ussd_cmd); + 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_type_cmd); diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index fd200c8..87a45bb 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -104,22 +104,29 @@ class TestVTYBSC(TestVTYBase): # Test invalid input self.vty.verify("bsc-msc-lost-text", ['% Command incomplete.']) + self.vty.verify("bsc-welcome-text", ['% Command incomplete.']) # Enable USSD notifications self.vty.verify("bsc-msc-lost-text MSC disconnected", ['']) + self.vty.verify("bsc-welcome-text Hello MS", ['']) # Verify settings res = self.vty.command("write terminal") self.assert_(res.find('bsc-msc-lost-text MSC disconnected') > 0) 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) # Now disable it.. self.vty.verify("no bsc-msc-lost-text", ['']) + self.vty.verify("no bsc-welcome-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) class TestVTYNAT(TestVTYBase): -- 1.7.9.5 From jpvw at truteq.com Wed Aug 28 14:28:31 2013 From: jpvw at truteq.com (J.P. van Wyk) Date: Wed, 28 Aug 2013 16:28:31 +0200 Subject: Newbie question on BS-11 firmware for first boot Message-ID: <521E090F.9010800@truteq.com> Good day list We acquired a BS-11 microBTS a while ago and in the preliminary stages of setting up the equipment came upon the following: background - 1. we installed OpenBSC as per the OpenBSC wiki. 2. we manufactured a serial cable to interact with the BS-11. 3. using bs11_config as per the bs11_config wiki page we started the BS-11 and got the following: $ ./bs11_config -p /dev/ttyUSB0 bs11_config (C) 2009 by Harald Welte and Dieter Spaar This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY LMT LOGON: ACK PHASE: 1 Warm Up Abis-link: Down PHASE: 1 Warm Up Abis-link: Down PHASE: 1 Warm Up Abis-link: Down . . PHASE: 1 Warm Up Abis-link: Down PHASE: 1 Software required Abis-link: Down No valid safety Load file "BTSBMC76.SWI" After this nothing further happens. From the wiki page I conclude that the file in question is the SMU safety load that is needed to create the minimal configuration to get the BS-11 to boot. There seem to be another firmware image needed for the BS-11 namely the HS011106.SWL Am I correct in my assumption that the BS-11 was not preloaded with this software? Where do I get these firmware images as the wiki page states that the project can't provide any of the firmware due to copyright constraints. Regards -- Paul van Wyk _____________________________________________________ TruTeq Wireless (Pty) Ltd. Tel +27 12 667 1530 http://www.truteq.com Fax +27 12 667 1531 Copyright & Legal: http://truteq.com/legal_notice.pdf From alexander.chemeris at gmail.com Wed Aug 28 19:17:37 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Wed, 28 Aug 2013 23:17:37 +0400 Subject: SMPP Submit_SM sender address Message-ID: Hi Harald, We're trying out SMPP interconnection and found that for Submit_SM (aka MT-SMS) sender is always set to an extension of subscriber ID 1. Looking into the code, this happens because we set "sms->sender" to point to subscriber ID 1 in submit_to_sms() function in SMPP code: /* fill in the source address */ sms->sender = subscr_get_by_id(net, 1); sms->src.ton = submit->source_addr_ton; sms->src.npi = submit->source_addr_npi; strncpy(sms->src.addr, (char *)submit->source_addr, sizeof(sms->src.addr)-1); And then src.addr/ton/npi are ignored when we store to the SMS DB and only subscriber ID is stored: /* FIXME: correct validity period */ result = dbi_conn_queryf(conn, "INSERT INTO SMS " "(created, sender_id, receiver_id, valid_until, " "reply_path_req, status_rep_req, protocol_id, " "data_coding_scheme, ud_hdr_ind, dest_addr, " "user_data, text) VALUES " "(datetime('now'), %llu, %llu, %u, " "%u, %u, %u, %u, %u, %s, %s, %s)", sms->sender->id, sms->receiver ? sms->receiver->id : 0, validity_timestamp, sms->reply_path_req, sms->status_rep_req, sms->protocol_id, sms->data_coding_scheme, sms->ud_hdr_ind, q_daddr, q_udata, q_text); So when we read SMS back from the DB, sender address is taken from that subscriber. It seems that a solution is to store actual ton/npi/addr in the SMS DB instead of storing ID. Then we could set sms->sender to NULL and just ignore it. Is there anything wrong with this approach? Otherwise we'll work on a patch to implement that. PS What is the current policy about changing DB layouts - just increase SCHEMA_REVISION? -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From holger at freyther.de Thu Aug 29 05:43:59 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 29 Aug 2013 07:43:59 +0200 Subject: SMPP Submit_SM sender address In-Reply-To: References: Message-ID: <20130829054359.GC15374@xiaoyu.lan> On Wed, Aug 28, 2013 at 11:17:37PM +0400, Alexander Chemeris wrote: > Hi Harald, Hi, http://git.osmocom.org/openbsc/commit/?h=zecke/features/sms-smpp&id=f3f051c010cd78c68af23b1e1cd342d14834c509 has already some work in progress for this. > PS What is the current policy about changing DB layouts - just > increase SCHEMA_REVISION? that is one of the reasons I didn't merge it. We should have schema migration. E.g. if you could create a patch that migrates an old SMS table to the new one that would be great. From alexander.chemeris at gmail.com Thu Aug 29 16:58:28 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Thu, 29 Aug 2013 20:58:28 +0400 Subject: SMPP Submit_SM sender address In-Reply-To: <20130829054359.GC15374@xiaoyu.lan> References: <20130829054359.GC15374@xiaoyu.lan> Message-ID: Hi Holger, On Thu, Aug 29, 2013 at 9:43 AM, Holger Hans Peter Freyther wrote: > On Wed, Aug 28, 2013 at 11:17:37PM +0400, Alexander Chemeris wrote: > http://git.osmocom.org/openbsc/commit/?h=zecke/features/sms-smpp&id=f3f051c010cd78c68af23b1e1cd342d14834c509 > > has already some work in progress for this. Thanks! >> PS What is the current policy about changing DB layouts - just >> increase SCHEMA_REVISION? > > that is one of the reasons I didn't merge it. We should have > schema migration. E.g. if you could create a patch that migrates > an old SMS table to the new one that would be great. Ok, I hope I'll find some time to create the patch. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From laforge at gnumonks.org Thu Aug 29 07:52:51 2013 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 29 Aug 2013 09:52:51 +0200 Subject: SMPP Submit_SM sender address In-Reply-To: References: Message-ID: <20130829075251.GB31743@nataraja.gnumonks.org> One more comment in addition to Holgers response: The problem you are describing only exists in store-and-forward mode, it doesn' exist when you select SMPP transaction mode. In the latter case, the SMS is not queued but immediately delivered to the MS, and an error returned if the MS is not reachable. And yes, the DB schema has to change, definitely. It was wrong to put the subscriber IDs in the SMS table in the first place. Regards, Harald On Wed, Aug 28, 2013 at 11:17:37PM +0400, Alexander Chemeris wrote: > Hi Harald, > > We're trying out SMPP interconnection and found that for Submit_SM > (aka MT-SMS) sender is always set to an extension of subscriber ID 1. > > Looking into the code, this happens because we set "sms->sender" to > point to subscriber ID 1 in submit_to_sms() function in SMPP code: > > /* fill in the source address */ > sms->sender = subscr_get_by_id(net, 1); > sms->src.ton = submit->source_addr_ton; > sms->src.npi = submit->source_addr_npi; > strncpy(sms->src.addr, (char *)submit->source_addr, sizeof(sms->src.addr)-1); > > And then src.addr/ton/npi are ignored when we store to the SMS DB and > only subscriber ID is stored: > > /* FIXME: correct validity period */ > result = dbi_conn_queryf(conn, > "INSERT INTO SMS " > "(created, sender_id, receiver_id, valid_until, " > "reply_path_req, status_rep_req, protocol_id, " > "data_coding_scheme, ud_hdr_ind, dest_addr, " > "user_data, text) VALUES " > "(datetime('now'), %llu, %llu, %u, " > "%u, %u, %u, %u, %u, %s, %s, %s)", > sms->sender->id, > sms->receiver ? sms->receiver->id : 0, validity_timestamp, > sms->reply_path_req, sms->status_rep_req, sms->protocol_id, > sms->data_coding_scheme, sms->ud_hdr_ind, > q_daddr, q_udata, q_text); > > So when we read SMS back from the DB, sender address is taken from > that subscriber. > > It seems that a solution is to store actual ton/npi/addr in the SMS DB > instead of storing ID. Then we could set sms->sender to NULL and just > ignore it. > > Is there anything wrong with this approach? Otherwise we'll work on a > patch to implement that. > > PS What is the current policy about changing DB layouts - just > increase SCHEMA_REVISION? > > -- > Regards, > Alexander Chemeris. > CEO, Fairwaves LLC / ??? ??????? > http://fairwaves.ru -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From alexander.chemeris at gmail.com Thu Aug 29 17:00:39 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Thu, 29 Aug 2013 21:00:39 +0400 Subject: SMPP Submit_SM sender address In-Reply-To: <20130829075251.GB31743@nataraja.gnumonks.org> References: <20130829075251.GB31743@nataraja.gnumonks.org> Message-ID: Yes, I figured that transaction mode should work, but we have to use async mode here, unfortunately. Regarding DB schema - Holger's patch looks sane to me. I would do it the same way if I implemented it. I hope it'll lend to master when we amend it with the DB update procedure. On Thu, Aug 29, 2013 at 11:52 AM, Harald Welte wrote: > One more comment in addition to Holgers response: > > The problem you are describing only exists in store-and-forward mode, it > doesn' exist when you select SMPP transaction mode. In the latter case, > the SMS is not queued but immediately delivered to the MS, and an error > returned if the MS is not reachable. > > And yes, the DB schema has to change, definitely. It was wrong to put > the subscriber IDs in the SMS table in the first place. > > Regards, > Harald > > On Wed, Aug 28, 2013 at 11:17:37PM +0400, Alexander Chemeris wrote: >> Hi Harald, >> >> We're trying out SMPP interconnection and found that for Submit_SM >> (aka MT-SMS) sender is always set to an extension of subscriber ID 1. >> >> Looking into the code, this happens because we set "sms->sender" to >> point to subscriber ID 1 in submit_to_sms() function in SMPP code: >> >> /* fill in the source address */ >> sms->sender = subscr_get_by_id(net, 1); >> sms->src.ton = submit->source_addr_ton; >> sms->src.npi = submit->source_addr_npi; >> strncpy(sms->src.addr, (char *)submit->source_addr, sizeof(sms->src.addr)-1); >> >> And then src.addr/ton/npi are ignored when we store to the SMS DB and >> only subscriber ID is stored: >> >> /* FIXME: correct validity period */ >> result = dbi_conn_queryf(conn, >> "INSERT INTO SMS " >> "(created, sender_id, receiver_id, valid_until, " >> "reply_path_req, status_rep_req, protocol_id, " >> "data_coding_scheme, ud_hdr_ind, dest_addr, " >> "user_data, text) VALUES " >> "(datetime('now'), %llu, %llu, %u, " >> "%u, %u, %u, %u, %u, %s, %s, %s)", >> sms->sender->id, >> sms->receiver ? sms->receiver->id : 0, validity_timestamp, >> sms->reply_path_req, sms->status_rep_req, sms->protocol_id, >> sms->data_coding_scheme, sms->ud_hdr_ind, >> q_daddr, q_udata, q_text); >> >> So when we read SMS back from the DB, sender address is taken from >> that subscriber. >> >> It seems that a solution is to store actual ton/npi/addr in the SMS DB >> instead of storing ID. Then we could set sms->sender to NULL and just >> ignore it. >> >> Is there anything wrong with this approach? Otherwise we'll work on a >> patch to implement that. >> >> PS What is the current policy about changing DB layouts - just >> increase SCHEMA_REVISION? >> >> -- >> Regards, >> Alexander Chemeris. >> CEO, Fairwaves LLC / ??? ??????? >> http://fairwaves.ru > > -- > - 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 alexander.chemeris at gmail.com Thu Aug 29 22:37:04 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Fri, 30 Aug 2013 02:37:04 +0400 Subject: SMPP Submit_SM sender address In-Reply-To: References: <20130829075251.GB31743@nataraja.gnumonks.org> Message-ID: Attached is an attempt to implement the conversion. I haven't tested it yet. If the general approach is correct, I'll test it tomorrow. PS For some reason this patch breaks build of channel_test, probably because it introduces gsm_network to db.c. I would appreciate if someone with better knowledge of libs interdependencies help me fix that. On Thu, Aug 29, 2013 at 9:00 PM, Alexander Chemeris wrote: > Yes, I figured that transaction mode should work, but we have to use > async mode here, unfortunately. > > Regarding DB schema - Holger's patch looks sane to me. I would do it > the same way if I implemented it. I hope it'll lend to master when we > amend it with the DB update procedure. > > On Thu, Aug 29, 2013 at 11:52 AM, Harald Welte wrote: >> One more comment in addition to Holgers response: >> >> The problem you are describing only exists in store-and-forward mode, it >> doesn' exist when you select SMPP transaction mode. In the latter case, >> the SMS is not queued but immediately delivered to the MS, and an error >> returned if the MS is not reachable. >> >> And yes, the DB schema has to change, definitely. It was wrong to put >> the subscriber IDs in the SMS table in the first place. >> >> Regards, >> Harald >> >> On Wed, Aug 28, 2013 at 11:17:37PM +0400, Alexander Chemeris wrote: >>> Hi Harald, >>> >>> We're trying out SMPP interconnection and found that for Submit_SM >>> (aka MT-SMS) sender is always set to an extension of subscriber ID 1. >>> >>> Looking into the code, this happens because we set "sms->sender" to >>> point to subscriber ID 1 in submit_to_sms() function in SMPP code: >>> >>> /* fill in the source address */ >>> sms->sender = subscr_get_by_id(net, 1); >>> sms->src.ton = submit->source_addr_ton; >>> sms->src.npi = submit->source_addr_npi; >>> strncpy(sms->src.addr, (char *)submit->source_addr, sizeof(sms->src.addr)-1); >>> >>> And then src.addr/ton/npi are ignored when we store to the SMS DB and >>> only subscriber ID is stored: >>> >>> /* FIXME: correct validity period */ >>> result = dbi_conn_queryf(conn, >>> "INSERT INTO SMS " >>> "(created, sender_id, receiver_id, valid_until, " >>> "reply_path_req, status_rep_req, protocol_id, " >>> "data_coding_scheme, ud_hdr_ind, dest_addr, " >>> "user_data, text) VALUES " >>> "(datetime('now'), %llu, %llu, %u, " >>> "%u, %u, %u, %u, %u, %s, %s, %s)", >>> sms->sender->id, >>> sms->receiver ? sms->receiver->id : 0, validity_timestamp, >>> sms->reply_path_req, sms->status_rep_req, sms->protocol_id, >>> sms->data_coding_scheme, sms->ud_hdr_ind, >>> q_daddr, q_udata, q_text); >>> >>> So when we read SMS back from the DB, sender address is taken from >>> that subscriber. >>> >>> It seems that a solution is to store actual ton/npi/addr in the SMS DB >>> instead of storing ID. Then we could set sms->sender to NULL and just >>> ignore it. >>> >>> Is there anything wrong with this approach? Otherwise we'll work on a >>> patch to implement that. >>> >>> PS What is the current policy about changing DB layouts - just >>> increase SCHEMA_REVISION? >>> >>> -- >>> Regards, >>> Alexander Chemeris. >>> CEO, Fairwaves LLC / ??? ??????? >>> http://fairwaves.ru >> >> -- >> - 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, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-sms-Add-a-function-to-update-DB-scheme-v3-to-v4.patch Type: application/octet-stream Size: 8239 bytes Desc: not available URL: From holger at freyther.de Thu Aug 29 16:36:16 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Thu, 29 Aug 2013 18:36:16 +0200 Subject: [PATCH] nanobts: Fix initialization of two concurrent BTS. Message-ID: <1377794176-11950-1-git-send-email-holger@freyther.de> From: Holger Hans Peter Freyther It was possible that the wrong NSEI information was sent to the BTS. This is because patch_nm_tables is not called before sending the data to the BTS. This will break when two BTS connect more or less at the same time. Stop using the arrays directly and instead introduce a method that will patch the table and return the data and length. This makes sure that all users patch the table before we send the data to the BTS. --- openbsc/src/libbsc/bts_ipaccess_nanobts.c | 66 ++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/openbsc/src/libbsc/bts_ipaccess_nanobts.c b/openbsc/src/libbsc/bts_ipaccess_nanobts.c index c8b235d..dfc8d16 100644 --- a/openbsc/src/libbsc/bts_ipaccess_nanobts.c +++ b/openbsc/src/libbsc/bts_ipaccess_nanobts.c @@ -265,6 +265,40 @@ static void patch_nm_tables(struct gsm_bts *bts) } } +static uint8_t *nanobts_attr_bts_get(struct gsm_bts *bts, size_t *data_len) +{ + patch_nm_tables(bts); + *data_len = sizeof(nanobts_attr_bts); + return nanobts_attr_bts; +} + +static uint8_t *nanobts_attr_nse_get(struct gsm_bts *bts, size_t *data_len) +{ + patch_nm_tables(bts); + *data_len = sizeof(nanobts_attr_nse); + return nanobts_attr_nse; +} + +static uint8_t *nanobts_attr_cell_get(struct gsm_bts *bts, size_t *data_len) +{ + patch_nm_tables(bts); + *data_len = sizeof(nanobts_attr_cell); + return nanobts_attr_cell; +} + +static uint8_t *nanobts_attr_nscv_get(struct gsm_bts *bts, size_t *data_len) +{ + patch_nm_tables(bts); + *data_len = sizeof(nanobts_attr_nsvc0); + return nanobts_attr_nsvc0; +} + +static uint8_t *nanobts_attr_radio_get(struct gsm_bts *bts, size_t *data_len) +{ + patch_nm_tables(bts); + *data_len = sizeof(nanobts_attr_radio); + return nanobts_attr_radio; +} /* Callback function to be called whenever we get a GSM 12.21 state change event */ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd) @@ -278,6 +312,9 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd) struct gsm_bts_trx_ts *ts; struct gsm_bts_gprs_nsvc *nsvc; + uint8_t *data; + size_t data_len; + if (!is_ipaccess_bts(nsd->bts)) return 0; @@ -300,9 +337,8 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd) case NM_OC_BTS: bts = obj; if (new_state->availability == NM_AVSTATE_DEPENDENCY) { - patch_nm_tables(bts); - abis_nm_set_bts_attr(bts, nanobts_attr_bts, - sizeof(nanobts_attr_bts)); + data = nanobts_attr_bts_get(bts, &data_len); + abis_nm_set_bts_attr(bts, data, data_len); abis_nm_chg_adm_state(bts, obj_class, bts->bts_nr, 0xff, 0xff, NM_STATE_UNLOCKED); @@ -315,7 +351,6 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd) trx = ts->trx; if (new_state->operational == NM_OPSTATE_DISABLED && new_state->availability == NM_AVSTATE_DEPENDENCY) { - patch_nm_tables(trx->bts); enum abis_nm_chan_comb ccomb = abis_nm_chcomb4pchan(ts->pchan); abis_nm_set_channel_attr(ts, ccomb); @@ -338,9 +373,9 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd) if (bts->gprs.mode == BTS_GPRS_NONE) break; if (new_state->availability == NM_AVSTATE_DEPENDENCY) { + data = nanobts_attr_nse_get(bts, &data_len); abis_nm_ipaccess_set_attr(bts, obj_class, bts->bts_nr, - 0xff, 0xff, nanobts_attr_nse, - sizeof(nanobts_attr_nse)); + 0xff, 0xff, data, data_len); abis_nm_opstart(bts, obj_class, bts->bts_nr, 0xff, 0xff); } @@ -350,9 +385,9 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd) if (bts->gprs.mode == BTS_GPRS_NONE) break; if (new_state->availability == NM_AVSTATE_DEPENDENCY) { + data = nanobts_attr_cell_get(bts, &data_len); abis_nm_ipaccess_set_attr(bts, obj_class, bts->bts_nr, - 0, 0xff, nanobts_attr_cell, - sizeof(nanobts_attr_cell)); + 0, 0xff, data, data_len); abis_nm_opstart(bts, obj_class, bts->bts_nr, 0, 0xff); abis_nm_chg_adm_state(bts, obj_class, bts->bts_nr, @@ -371,10 +406,10 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd) break; if ((new_state->availability == NM_AVSTATE_OFF_LINE) || (new_state->availability == NM_AVSTATE_DEPENDENCY)) { + data = nanobts_attr_nscv_get(bts, &data_len); abis_nm_ipaccess_set_attr(bts, obj_class, bts->bts_nr, nsvc->id, 0xff, - nanobts_attr_nsvc0, - sizeof(nanobts_attr_nsvc0)); + data, data_len); abis_nm_opstart(bts, obj_class, bts->bts_nr, nsvc->id, 0xff); abis_nm_chg_adm_state(bts, obj_class, bts->bts_nr, @@ -424,11 +459,12 @@ static int sw_activ_rep(struct msgb *mb) */ int rc_state = trx->mo.nm_state.administrative; /* Patch ARFCN into radio attribute */ - nanobts_attr_radio[5] &= 0xf0; - nanobts_attr_radio[5] |= trx->arfcn >> 8; - nanobts_attr_radio[6] = trx->arfcn & 0xff; - abis_nm_set_radio_attr(trx, nanobts_attr_radio, - sizeof(nanobts_attr_radio)); + size_t data_len; + uint8_t *data = nanobts_attr_radio_get(trx->bts, &data_len); + data[5] &= 0xf0; + data[5] |= trx->arfcn >> 8; + data[6] = trx->arfcn & 0xff; + abis_nm_set_radio_attr(trx, data, data_len); abis_nm_chg_adm_state(trx->bts, foh->obj_class, trx->bts->bts_nr, trx->nr, 0xff, rc_state); -- 1.8.3.2 From alexander.chemeris at gmail.com Thu Aug 29 22:38:49 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Fri, 30 Aug 2013 02:38:49 +0400 Subject: [PATCH] build: Don't llink with libbsc twice Message-ID: Hi, As the caption states, it removes duplicated library linkage. in tests/db/Makefile.am. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-build-Don-t-llink-with-libbsc-twice.patch Type: application/octet-stream Size: 885 bytes Desc: not available URL: From holger at freyther.de Fri Aug 30 07:23:30 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 30 Aug 2013 09:23:30 +0200 Subject: [PATCH] build: Don't llink with libbsc twice In-Reply-To: References: Message-ID: <20130830072330.GH15374@xiaoyu.lan> On Fri, Aug 30, 2013 at 02:38:49AM +0400, Alexander Chemeris wrote: > Hi, > > As the caption states, it removes duplicated library linkage. in > tests/db/Makefile.am. Please take a look at 93d4394d1d0e14a71e6cead8a895907c92cf7784. I don't think the underlying issue has changed. holger From alexander.chemeris at gmail.com Fri Aug 30 07:26:53 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Fri, 30 Aug 2013 11:26:53 +0400 Subject: [PATCH] build: Don't llink with libbsc twice In-Reply-To: <20130830072330.GH15374@xiaoyu.lan> References: <20130830072330.GH15374@xiaoyu.lan> Message-ID: On Fri, Aug 30, 2013 at 11:23 AM, Holger Hans Peter Freyther wrote: > On Fri, Aug 30, 2013 at 02:38:49AM +0400, Alexander Chemeris wrote: >> Hi, >> >> As the caption states, it removes duplicated library linkage. in >> tests/db/Makefile.am. > > Please take a look at 93d4394d1d0e14a71e6cead8a895907c92cf7784. I don't > think the underlying issue has changed. I see. Just curious - what version of the compiler is affected? Here is works fine on gcc 4.6.3 (Ubuntu 12.04). -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From holger at freyther.de Fri Aug 30 07:51:34 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 30 Aug 2013 09:51:34 +0200 Subject: [PATCH] build: Don't llink with libbsc twice In-Reply-To: References: <20130830072330.GH15374@xiaoyu.lan> Message-ID: <20130830075134.GI15374@xiaoyu.lan> On Fri, Aug 30, 2013 at 11:26:53AM +0400, Alexander Chemeris wrote: > Just curious - what version of the compiler is affected? > Here is works fine on gcc 4.6.3 (Ubuntu 12.04). It is not the compiler but the linker. And it is a good case for a commit message that failed to capture this information. The proof your commit needs to make is that there are no cyclic dependencies between the libs (but I think we still have them). From jerlbeck at sysmocom.de Fri Aug 30 16:33:58 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Fri, 30 Aug 2013 18:33:58 +0200 Subject: [PATCH 1/6] vty: Fix BSC_NODE prompt string Message-ID: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> Change '%s(bsc)#' to '%s(config-bsc)# '. The missing trailing blank brakes osmopy's VTYInteract.command() because the blank is contained in the end patterns which are checked to decide whether to leave the select loop. Thus trying to execute the 'bsc' command there blocks the test script forever. --- openbsc/src/osmo-bsc/osmo_bsc_vty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 8eaa55b..f6cf1a0 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -43,7 +43,7 @@ static struct osmo_msc_data *osmo_msc_data(struct vty *vty) static struct cmd_node bsc_node = { BSC_NODE, - "%s(bsc)#", + "%s(config-bsc)# ", 1, }; -- 1.7.9.5 From jerlbeck at sysmocom.de Fri Aug 30 16:33:59 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Fri, 30 Aug 2013 18:33:59 +0200 Subject: [PATCH 2/6] 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: <1377880443-25900-2-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 | 156 +++++++++++++++++++++++++++++++++++++- 1 file changed, 153 insertions(+), 3 deletions(-) diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 87a45bb..7b8498b 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 TestVTYGenericBTS(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.vty.verify("configure terminal",['']) + self.assertEquals(self.vty.node(), 'config') + # self.checkForEndAndExit() + self.vty.verify("network",['']) + self.assertEquals(self.vty.node(), 'config-net') + self.checkForEndAndExit() + self.vty.verify("bts 0",['']) + self.assertEquals(self.vty.node(), 'config-net-bts') + self.checkForEndAndExit() + self.vty.verify("trx 0",['']) + self.assertEquals(self.vty.node(), 'config-net-bts-trx') + self.checkForEndAndExit() + self.vty.verify("exit",['']) + self.assertEquals(self.vty.node(), 'config-net-bts') + self.vty.verify("exit",['']) + self.assertEquals(self.vty.node(), 'config-net') + self.vty.verify("exit",['']) + self.assertEquals(self.vty.node(), 'config') + self.vty.verify("exit",['']) + self.assertTrue(self.vty.node() is None) + +class TestVTYNITB(TestVTYGenericBTS): def vty_command(self): return ["./src/osmo-nitb/osmo-nitb", "-c", @@ -65,6 +111,39 @@ 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.vty.verify("configure terminal", ['']) + self.assertEquals(self.vty.node(), 'config') + self.ignoredCheckForEndAndExit() + self.vty.verify('mncc-int', ['']) + self.assertEquals(self.vty.node(), 'config-mncc-int') + self.checkForEndAndExit() + if self.notIgnoredTest(): + self.vty.verify('exit', ['']) + self.assertEquals(self.vty.node(), 'config') + else: + self.vty.verify("configure terminal", ['']) + self.vty.verify('smpp', ['']) + self.assertEquals(self.vty.node(), 'config-smpp') + self.ignoredCheckForEndAndExit() + self.vty.verify("exit", ['']) + if self.notIgnoredTest(): + self.assertEquals(self.vty.node(), 'config') + 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 +167,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(TestVTYGenericBTS): def vty_command(self): return ["./src/osmo-bsc/osmo-bsc", "-c", @@ -97,6 +176,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.vty.verify("configure terminal", ['']) + self.assertEquals(self.vty.node(), 'config') + # self.ignoredCheckForEndAndExit() + self.vty.verify("msc 0", ['']) + self.assertEquals(self.vty.node(), 'config-msc') + # self.ignoredCheckForEndAndExit() + self.vty.verify("exit", ['']) + if self.notIgnoredTest(): + self.assertEquals(self.vty.node(), 'config') + else: + self.vty.verify("configure terminal", ['']) + self.vty.command("bsc") + self.assertEquals(self.vty.node(), 'config-bsc') + self.ignoredCheckForEndAndExit() + self.vty.verify("exit", ['']) + if self.notIgnoredTest(): + self.assertEquals(self.vty.node(), 'config') + else: + self.vty.verify("configure terminal", ['']) + 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 +242,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(TestVTYGenericBTS): def vty_command(self): return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-c", @@ -137,6 +251,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.vty.verify('configure terminal', ['']) + self.assertEquals(self.vty.node(), 'config') + # self.checkForEndAndExit() + self.vty.verify('mgcp', ['']) + self.assertEquals(self.vty.node(), 'config-mgcp') + self.checkForEndAndExit() + self.vty.verify('exit', ['']) + self.assertEquals(self.vty.node(), 'config') + self.vty.verify('nat', ['']) + self.assertEquals(self.vty.node(), 'config-nat') + self.checkForEndAndExit() + self.vty.verify('bsc 0', ['']) + self.assertEquals(self.vty.node(), 'config-nat-bsc') + self.checkForEndAndExit() + self.vty.verify('exit', ['']) + self.assertEquals(self.vty.node(), 'config-nat') + self.vty.verify('exit', ['']) + self.assertEquals(self.vty.node(), 'config') + 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 holger at freyther.de Sat Aug 31 13:41:28 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sat, 31 Aug 2013 15:41:28 +0200 Subject: [PATCH 2/6] vty: Add test to check vty node hierarchy and related commands In-Reply-To: <1377880443-25900-2-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1377880443-25900-2-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130831134128.GF28152@xiaoyu.lan> 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. > + 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. From jerlbeck at sysmocom.de Fri Aug 30 16:34:00 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Fri, 30 Aug 2013 18:34:00 +0200 Subject: [PATCH 3/6] vty: Generalize ournode_exit() and ournode_end() In-Reply-To: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1377880443-25900-3-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 ++++++++++-------------------------- openbsc/tests/vty_test_runner.py | 65 +++++++++-------- 2 files changed, 68 insertions(+), 137 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; } diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 7b8498b..4426860 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -81,25 +81,25 @@ class TestVTYGenericBTS(TestVTYBase): def _testConfigNetworkTree(self): self.vty.enable() - self.vty.verify("configure terminal",['']) + self.assertTrue(self.vty.verify("configure terminal",[''])) self.assertEquals(self.vty.node(), 'config') # self.checkForEndAndExit() - self.vty.verify("network",['']) + self.assertTrue(self.vty.verify("network",[''])) self.assertEquals(self.vty.node(), 'config-net') self.checkForEndAndExit() - self.vty.verify("bts 0",['']) + self.assertTrue(self.vty.verify("bts 0",[''])) self.assertEquals(self.vty.node(), 'config-net-bts') self.checkForEndAndExit() - self.vty.verify("trx 0",['']) + self.assertTrue(self.vty.verify("trx 0",[''])) self.assertEquals(self.vty.node(), 'config-net-bts-trx') self.checkForEndAndExit() - self.vty.verify("exit",['']) + self.assertTrue(self.vty.verify("exit",[''])) self.assertEquals(self.vty.node(), 'config-net-bts') - self.vty.verify("exit",['']) + self.assertTrue(self.vty.verify("exit",[''])) self.assertEquals(self.vty.node(), 'config-net') - self.vty.verify("exit",['']) + self.assertTrue(self.vty.verify("exit",[''])) self.assertEquals(self.vty.node(), 'config') - self.vty.verify("exit",['']) + self.assertTrue(self.vty.verify("exit",[''])) self.assertTrue(self.vty.node() is None) class TestVTYNITB(TestVTYGenericBTS): @@ -116,24 +116,23 @@ class TestVTYNITB(TestVTYGenericBTS): def testVtyTree(self): self.vty.enable() - self.vty.verify("configure terminal", ['']) + self.assertTrue(self.vty.verify("configure terminal", [''])) self.assertEquals(self.vty.node(), 'config') self.ignoredCheckForEndAndExit() - self.vty.verify('mncc-int', ['']) + self.assertTrue(self.vty.verify('mncc-int', [''])) self.assertEquals(self.vty.node(), 'config-mncc-int') self.checkForEndAndExit() - if self.notIgnoredTest(): - self.vty.verify('exit', ['']) - self.assertEquals(self.vty.node(), 'config') - else: - self.vty.verify("configure terminal", ['']) - self.vty.verify('smpp', ['']) + 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.vty.verify("exit", ['']) + self.assertTrue(self.vty.verify("exit", [''])) if self.notIgnoredTest(): self.assertEquals(self.vty.node(), 'config') - self.vty.verify("exit", ['']) + 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 @@ -181,26 +180,26 @@ class TestVTYBSC(TestVTYGenericBTS): def testVtyTree(self): self.vty.enable() - self.vty.verify("configure terminal", ['']) + self.assertTrue(self.vty.verify("configure terminal", [''])) self.assertEquals(self.vty.node(), 'config') # self.ignoredCheckForEndAndExit() - self.vty.verify("msc 0", ['']) + self.assertTrue(self.vty.verify("msc 0", [''])) self.assertEquals(self.vty.node(), 'config-msc') # self.ignoredCheckForEndAndExit() - self.vty.verify("exit", ['']) + self.assertTrue(self.vty.verify("exit", [''])) if self.notIgnoredTest(): self.assertEquals(self.vty.node(), 'config') else: - self.vty.verify("configure terminal", ['']) + self.assertTrue(self.vty.verify("configure terminal", [''])) self.vty.command("bsc") self.assertEquals(self.vty.node(), 'config-bsc') self.ignoredCheckForEndAndExit() - self.vty.verify("exit", ['']) + self.assertTrue(self.vty.verify("exit", [''])) if self.notIgnoredTest(): self.assertEquals(self.vty.node(), 'config') else: - self.vty.verify("configure terminal", ['']) - self.vty.verify("exit", ['']) + 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 @@ -253,25 +252,25 @@ class TestVTYNAT(TestVTYGenericBTS): def testVtyTree(self): self.vty.enable() - self.vty.verify('configure terminal', ['']) + self.assertTrue(self.vty.verify('configure terminal', [''])) self.assertEquals(self.vty.node(), 'config') # self.checkForEndAndExit() - self.vty.verify('mgcp', ['']) + self.assertTrue(self.vty.verify('mgcp', [''])) self.assertEquals(self.vty.node(), 'config-mgcp') self.checkForEndAndExit() - self.vty.verify('exit', ['']) + self.assertTrue(self.vty.verify('exit', [''])) self.assertEquals(self.vty.node(), 'config') - self.vty.verify('nat', ['']) + self.assertTrue(self.vty.verify('nat', [''])) self.assertEquals(self.vty.node(), 'config-nat') self.checkForEndAndExit() - self.vty.verify('bsc 0', ['']) + self.assertTrue(self.vty.verify('bsc 0', [''])) self.assertEquals(self.vty.node(), 'config-nat-bsc') self.checkForEndAndExit() - self.vty.verify('exit', ['']) + self.assertTrue(self.vty.verify('exit', [''])) self.assertEquals(self.vty.node(), 'config-nat') - self.vty.verify('exit', ['']) + self.assertTrue(self.vty.verify('exit', [''])) self.assertEquals(self.vty.node(), 'config') - self.vty.verify('exit', ['']) + self.assertTrue(self.vty.verify('exit', [''])) self.assertTrue(self.vty.node() is None) # Check searching for outer node's commands -- 1.7.9.5 From holger at freyther.de Sat Aug 31 13:47:56 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sat, 31 Aug 2013 15:47:56 +0200 Subject: [PATCH 3/6] vty: Generalize ournode_exit() and ournode_end() In-Reply-To: <1377880443-25900-3-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1377880443-25900-3-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130831134756.GG28152@xiaoyu.lan> 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 > @@ -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? > 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? From jerlbeck at sysmocom.de Fri Aug 30 16:34:01 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Fri, 30 Aug 2013 18:34:01 +0200 Subject: [PATCH 4/6] vty: Add bsc_install_default() and replace all install_default() In-Reply-To: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1377880443-25900-4-git-send-email-jerlbeck@sysmocom.de> This patch only adds bsc_install_default() and does the renaming so that in can be reverted easily if the generic handling of exit and end is moved to libosmocore. Since it breaks the vty test suites due to duplicated commands, those suites have been disabled completely. --- openbsc/include/openbsc/vty.h | 2 ++ openbsc/src/gprs/gb_proxy_vty.c | 2 +- openbsc/src/gprs/sgsn_vty.c | 2 +- openbsc/src/libbsc/abis_nm_vty.c | 2 +- openbsc/src/libbsc/abis_om2000_vty.c | 2 +- openbsc/src/libbsc/bsc_vty.c | 8 ++++---- openbsc/src/libcommon/common_vty.c | 10 ++++++++++ openbsc/src/libmgcp/mgcp_vty.c | 4 ++-- openbsc/src/libmsc/smpp_vty.c | 4 ++-- openbsc/src/libmsc/vty_interface_layer3.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_vty.c | 4 ++-- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 6 +++--- openbsc/tests/vty_test_runner.py | 22 ++++++++-------------- 13 files changed, 38 insertions(+), 32 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..ccbeead 100644 --- a/openbsc/src/gprs/gb_proxy_vty.c +++ b/openbsc/src/gprs/gb_proxy_vty.c @@ -82,7 +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); + bsc_install_default(GBPROXY_NODE); install_element(GBPROXY_NODE, &ournode_exit_cmd); install_element(GBPROXY_NODE, &ournode_end_cmd); install_element(GBPROXY_NODE, &cfg_nsip_sgsn_nsei_cmd); diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index a4ba280..1acaae7 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -418,7 +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); + bsc_install_default(SGSN_NODE); install_element(SGSN_NODE, &ournode_exit_cmd); install_element(SGSN_NODE, &ournode_end_cmd); install_element(SGSN_NODE, &cfg_sgsn_bind_addr_cmd); diff --git a/openbsc/src/libbsc/abis_nm_vty.c b/openbsc/src/libbsc/abis_nm_vty.c index fd60210..6ac931a 100644 --- a/openbsc/src/libbsc/abis_nm_vty.c +++ b/openbsc/src/libbsc/abis_nm_vty.c @@ -183,7 +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); + bsc_install_default(OML_NODE); install_element(OML_NODE, &ournode_exit_cmd); 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..57bed8a 100644 --- a/openbsc/src/libbsc/abis_om2000_vty.c +++ b/openbsc/src/libbsc/abis_om2000_vty.c @@ -445,7 +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); + bsc_install_default(OM2K_NODE); install_element(OM2K_NODE, &ournode_exit_cmd); install_element(OM2K_NODE, &om2k_reset_cmd); install_element(OM2K_NODE, &om2k_start_cmd); diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 45df90f..ca6ff4c 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -3002,7 +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); + bsc_install_default(GSMNET_NODE); install_element(GSMNET_NODE, &ournode_exit_cmd); install_element(GSMNET_NODE, &ournode_end_cmd); install_element(GSMNET_NODE, &cfg_net_ncc_cmd); @@ -3040,7 +3040,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); + bsc_install_default(BTS_NODE); install_element(BTS_NODE, &ournode_exit_cmd); install_element(BTS_NODE, &ournode_end_cmd); install_element(BTS_NODE, &cfg_bts_type_cmd); @@ -3102,7 +3102,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); + bsc_install_default(TRX_NODE); install_element(TRX_NODE, &ournode_exit_cmd); install_element(TRX_NODE, &ournode_end_cmd); install_element(TRX_NODE, &cfg_trx_arfcn_cmd); @@ -3116,7 +3116,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); + bsc_install_default(TS_NODE); install_element(TS_NODE, &ournode_exit_cmd); install_element(TS_NODE, &ournode_end_cmd); install_element(TS_NODE, &cfg_ts_pchan_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..ccb9c26 100644 --- a/openbsc/src/libmgcp/mgcp_vty.c +++ b/openbsc/src/libmgcp/mgcp_vty.c @@ -786,7 +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); + bsc_install_default(MGCP_NODE); install_element(MGCP_NODE, &ournode_exit_cmd); install_element(MGCP_NODE, &ournode_end_cmd); install_element(MGCP_NODE, &cfg_mgcp_local_ip_cmd); @@ -820,7 +820,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); + bsc_install_default(TRUNK_NODE); install_element(TRUNK_NODE, &ournode_exit_cmd); install_element(TRUNK_NODE, &ournode_end_cmd); install_element(TRUNK_NODE, &cfg_trunk_payload_number_cmd); 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..ce06837 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -975,7 +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); + bsc_install_default(MNCC_INT_NODE); install_element(MNCC_INT_NODE, &ournode_exit_cmd); install_element(MNCC_INT_NODE, &ournode_end_cmd); install_element(MNCC_INT_NODE, &mnccint_def_codec_f_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..5699223 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -1192,7 +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); + bsc_install_default(NAT_NODE); install_element(NAT_NODE, &ournode_exit_cmd); install_element(NAT_NODE, &ournode_end_cmd); install_element(NAT_NODE, &cfg_nat_msc_ip_cmd); @@ -1235,7 +1235,7 @@ 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); + bsc_install_default(PGROUP_NODE); install_element(PGROUP_NODE, &ournode_exit_cmd); install_element(PGROUP_NODE, &ournode_end_cmd); install_element(PGROUP_NODE, &cfg_pgroup_lac_cmd); @@ -1244,7 +1244,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) /* BSC subgroups */ install_element(NAT_NODE, &cfg_bsc_cmd); install_node(&bsc_node, config_write_bsc); - install_default(NAT_BSC_NODE); + bsc_install_default(NAT_BSC_NODE); install_element(NAT_BSC_NODE, &ournode_exit_cmd); install_element(NAT_BSC_NODE, &ournode_end_cmd); install_element(NAT_BSC_NODE, &cfg_bsc_token_cmd); diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 4426860..725eb10 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -182,23 +182,17 @@ class TestVTYBSC(TestVTYGenericBTS): self.vty.enable() self.assertTrue(self.vty.verify("configure terminal", [''])) self.assertEquals(self.vty.node(), 'config') - # self.ignoredCheckForEndAndExit() + 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.vty.command("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) @@ -414,8 +408,8 @@ if __name__ == '__main__': os.chdir(workdir) print "Running tests for specific VTY commands" suite = unittest.TestSuite() - suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYNITB)) - add_bsc_test(suite, workdir) - add_nat_test(suite, workdir) + #suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYNITB)) + #add_bsc_test(suite, workdir) + #add_nat_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 Fri Aug 30 16:34:02 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Fri, 30 Aug 2013 18:34:02 +0200 Subject: [PATCH 5/6] vty: Remove duplicated 'exit' and 'end' 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: <1377880443-25900-5-git-send-email-jerlbeck@sysmocom.de> Since 'exit' and 'end' are added automatically to each node, the explicit registrations of these commands are removed by this patch. The related test succeed now without work-arounds (except for the 'config' node itself which is part of libosmocore). --- openbsc/src/gprs/gb_proxy_vty.c | 2 -- openbsc/src/gprs/sgsn_vty.c | 2 -- openbsc/src/libbsc/abis_nm_vty.c | 1 - openbsc/src/libbsc/abis_om2000_vty.c | 1 - openbsc/src/libbsc/bsc_vty.c | 8 -------- openbsc/src/libmgcp/mgcp_vty.c | 4 ---- openbsc/src/libmsc/vty_interface_layer3.c | 2 -- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 6 ------ openbsc/tests/vty_test_runner.py | 15 ++++++--------- 9 files changed, 6 insertions(+), 35 deletions(-) diff --git a/openbsc/src/gprs/gb_proxy_vty.c b/openbsc/src/gprs/gb_proxy_vty.c index ccbeead..63546d3 100644 --- a/openbsc/src/gprs/gb_proxy_vty.c +++ b/openbsc/src/gprs/gb_proxy_vty.c @@ -83,8 +83,6 @@ int gbproxy_vty_init(void) install_element(CONFIG_NODE, &cfg_gbproxy_cmd); install_node(&gbproxy_node, config_write_gbproxy); bsc_install_default(GBPROXY_NODE); - install_element(GBPROXY_NODE, &ournode_exit_cmd); - install_element(GBPROXY_NODE, &ournode_end_cmd); 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 1acaae7..8106b7d 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -419,8 +419,6 @@ int sgsn_vty_init(void) install_element(CONFIG_NODE, &cfg_sgsn_cmd); install_node(&sgsn_node, config_write_sgsn); bsc_install_default(SGSN_NODE); - install_element(SGSN_NODE, &ournode_exit_cmd); - install_element(SGSN_NODE, &ournode_end_cmd); 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 6ac931a..5db667d 100644 --- a/openbsc/src/libbsc/abis_nm_vty.c +++ b/openbsc/src/libbsc/abis_nm_vty.c @@ -184,7 +184,6 @@ int abis_nm_vty_init(void) install_node(&oml_node, dummy_config_write); bsc_install_default(OML_NODE); - install_element(OML_NODE, &ournode_exit_cmd); 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 57bed8a..eb8f4d5 100644 --- a/openbsc/src/libbsc/abis_om2000_vty.c +++ b/openbsc/src/libbsc/abis_om2000_vty.c @@ -446,7 +446,6 @@ int abis_om2k_vty_init(void) install_node(&om2k_node, dummy_config_write); bsc_install_default(OM2K_NODE); - install_element(OM2K_NODE, &ournode_exit_cmd); 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 ca6ff4c..5748945 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -3003,8 +3003,6 @@ int bsc_vty_init(const struct log_info *cat) install_element(CONFIG_NODE, &cfg_net_cmd); install_node(&net_node, config_write_net); bsc_install_default(GSMNET_NODE); - install_element(GSMNET_NODE, &ournode_exit_cmd); - install_element(GSMNET_NODE, &ournode_end_cmd); 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); @@ -3041,8 +3039,6 @@ int bsc_vty_init(const struct log_info *cat) install_element(GSMNET_NODE, &cfg_bts_cmd); install_node(&bts_node, config_write_bts); bsc_install_default(BTS_NODE); - install_element(BTS_NODE, &ournode_exit_cmd); - install_element(BTS_NODE, &ournode_end_cmd); install_element(BTS_NODE, &cfg_bts_type_cmd); install_element(BTS_NODE, &cfg_description_cmd); install_element(BTS_NODE, &cfg_no_description_cmd); @@ -3103,8 +3099,6 @@ int bsc_vty_init(const struct log_info *cat) install_element(BTS_NODE, &cfg_trx_cmd); install_node(&trx_node, dummy_config_write); bsc_install_default(TRX_NODE); - install_element(TRX_NODE, &ournode_exit_cmd); - install_element(TRX_NODE, &ournode_end_cmd); install_element(TRX_NODE, &cfg_trx_arfcn_cmd); install_element(TRX_NODE, &cfg_description_cmd); install_element(TRX_NODE, &cfg_no_description_cmd); @@ -3117,8 +3111,6 @@ int bsc_vty_init(const struct log_info *cat) install_element(TRX_NODE, &cfg_ts_cmd); install_node(&ts_node, dummy_config_write); bsc_install_default(TS_NODE); - install_element(TS_NODE, &ournode_exit_cmd); - install_element(TS_NODE, &ournode_end_cmd); 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/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c index ccb9c26..9421f4f 100644 --- a/openbsc/src/libmgcp/mgcp_vty.c +++ b/openbsc/src/libmgcp/mgcp_vty.c @@ -787,8 +787,6 @@ int mgcp_vty_init(void) install_node(&mgcp_node, config_write_mgcp); bsc_install_default(MGCP_NODE); - install_element(MGCP_NODE, &ournode_exit_cmd); - install_element(MGCP_NODE, &ournode_end_cmd); 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); @@ -821,8 +819,6 @@ int mgcp_vty_init(void) install_element(MGCP_NODE, &cfg_mgcp_trunk_cmd); install_node(&trunk_node, config_write_trunk); bsc_install_default(TRUNK_NODE); - install_element(TRUNK_NODE, &ournode_exit_cmd); - install_element(TRUNK_NODE, &ournode_end_cmd); 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/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index ce06837..19c78ea 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -976,8 +976,6 @@ int bsc_vty_init_extra(void) install_element(CONFIG_NODE, &cfg_mncc_int_cmd); install_node(&mncc_int_node, config_write_mncc_int); bsc_install_default(MNCC_INT_NODE); - install_element(MNCC_INT_NODE, &ournode_exit_cmd); - install_element(MNCC_INT_NODE, &ournode_end_cmd); 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_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 5699223..511d62a 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -1193,8 +1193,6 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element(CONFIG_NODE, &cfg_nat_cmd); install_node(&nat_node, config_write_nat); bsc_install_default(NAT_NODE); - install_element(NAT_NODE, &ournode_exit_cmd); - install_element(NAT_NODE, &ournode_end_cmd); 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); @@ -1236,8 +1234,6 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element(NAT_NODE, &cfg_nat_no_pgroup_cmd); install_node(&pgroup_node, config_write_pgroup); bsc_install_default(PGROUP_NODE); - install_element(PGROUP_NODE, &ournode_exit_cmd); - install_element(PGROUP_NODE, &ournode_end_cmd); install_element(PGROUP_NODE, &cfg_pgroup_lac_cmd); install_element(PGROUP_NODE, &cfg_pgroup_no_lac_cmd); @@ -1245,8 +1241,6 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element(NAT_NODE, &cfg_bsc_cmd); install_node(&bsc_node, config_write_bsc); bsc_install_default(NAT_BSC_NODE); - install_element(NAT_BSC_NODE, &ournode_exit_cmd); - install_element(NAT_BSC_NODE, &ournode_end_cmd); 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 725eb10..7783189 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -83,7 +83,7 @@ class TestVTYGenericBTS(TestVTYBase): self.vty.enable() self.assertTrue(self.vty.verify("configure terminal",[''])) self.assertEquals(self.vty.node(), 'config') - # self.checkForEndAndExit() + self.ignoredCheckForEndAndExit() self.assertTrue(self.vty.verify("network",[''])) self.assertEquals(self.vty.node(), 'config-net') self.checkForEndAndExit() @@ -128,10 +128,7 @@ class TestVTYNITB(TestVTYGenericBTS): 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) @@ -248,7 +245,7 @@ class TestVTYNAT(TestVTYGenericBTS): self.vty.enable() self.assertTrue(self.vty.verify('configure terminal', [''])) self.assertEquals(self.vty.node(), 'config') - # self.checkForEndAndExit() + self.ignoredCheckForEndAndExit() self.assertTrue(self.vty.verify('mgcp', [''])) self.assertEquals(self.vty.node(), 'config-mgcp') self.checkForEndAndExit() @@ -408,8 +405,8 @@ if __name__ == '__main__': os.chdir(workdir) print "Running tests for specific VTY commands" suite = unittest.TestSuite() - #suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYNITB)) - #add_bsc_test(suite, workdir) - #add_nat_test(suite, workdir) + suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVTYNITB)) + add_bsc_test(suite, workdir) + add_nat_test(suite, workdir) res = unittest.TextTestRunner(verbosity=verbose_level).run(suite) sys.exit(len(res.errors) + len(res.failures)) -- 1.7.9.5 From holger at freyther.de Sat Aug 31 13:50:10 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sat, 31 Aug 2013 15:50:10 +0200 Subject: [PATCH 5/6] vty: Remove duplicated 'exit' and 'end' commands In-Reply-To: <1377880443-25900-5-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1377880443-25900-5-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130831135010.GH28152@xiaoyu.lan> On Fri, Aug 30, 2013 at 06:34:02PM +0200, Jacob Erlbeck wrote: Dear Jacob, > Since 'exit' and 'end' are added automatically to each node, the > explicit registrations of these commands are removed by this patch. I know I asked you to make two separate patches but after seing what I asked for, I think I would like to squash the previous and this commit together. Any objection? thanks for the patch set! From jerlbeck at sysmocom.de Fri Aug 30 16:34:03 2013 From: jerlbeck at sysmocom.de (Jacob Erlbeck) Date: Fri, 30 Aug 2013 18:34:03 +0200 Subject: [PATCH 6/6] vty: Rename 'mgcp-through-msc-ipa' command to 'use-msc-ipa-for-mgcp' In-Reply-To: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <1377880443-25900-6-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 7783189..06202e1 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -269,13 +269,13 @@ class TestVTYNAT(TestVTYGenericBTS): 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 holger at freyther.de Sat Aug 31 13:50:37 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sat, 31 Aug 2013 15:50:37 +0200 Subject: [PATCH 6/6] vty: Rename 'mgcp-through-msc-ipa' command to 'use-msc-ipa-for-mgcp' In-Reply-To: <1377880443-25900-6-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> <1377880443-25900-6-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130831135037.GI28152@xiaoyu.lan> On Fri, Aug 30, 2013 at 06:34:03PM +0200, Jacob Erlbeck wrote: > 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. Looks good! From holger at freyther.de Sat Aug 31 13:36:10 2013 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sat, 31 Aug 2013 15:36:10 +0200 Subject: [PATCH 1/6] vty: Fix BSC_NODE prompt string In-Reply-To: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> References: <1377880443-25900-1-git-send-email-jerlbeck@sysmocom.de> Message-ID: <20130831133610.GE28152@xiaoyu.lan> On Fri, Aug 30, 2013 at 06:33:58PM +0200, Jacob Erlbeck wrote: > Change '%s(bsc)#' to '%s(config-bsc)# '. The missing trailing blank > brakes osmopy's VTYInteract.command() because the blank is contained s/brake/break/, i have modified this locally. From jolly at eversberg.eu Sat Aug 31 18:30:40 2013 From: jolly at eversberg.eu (Andreas Eversberg) Date: Sat, 31 Aug 2013 20:30:40 +0200 Subject: [PATCH 2/8] Add MEAS (MPH_INFO) IND message to PH-/MPH-/TCH-SAP interface Message-ID: This part moves processing of measurement infos from osmo-bts-sysmo to common part. --- src/common/l1sap.c | 32 ++++++++++++++++++++++++++++++++ src/osmo-bts-sysmo/l1_if.c | 26 +++++++++++++------------- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/common/l1sap.c b/src/common/l1sap.c index 9c7a9c6..c1e9f9f 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -155,6 +155,35 @@ static int l1sap_info_time_ind(struct gsm_bts_trx *trx, return 0; } +/* measurement information received from bts model */ +static int l1sap_info_meas_ind(struct gsm_bts_trx *trx, + struct osmo_phsap_prim *l1sap, + struct info_meas_ind_param *info_meas_ind) +{ + struct bts_ul_meas ulm; + struct gsm_lchan *lchan; + + DEBUGP(DL1P, "MPH_INFO meas ind chan_nr=%02x\n", + info_meas_ind->chan_nr); + + lchan = &trx->ts[L1SAP_CHAN2TS(info_meas_ind->chan_nr)] + .lchan[l1sap_chan2ss(info_meas_ind->chan_nr)]; + + /* in the GPRS case we are not interested in measurement + * processing. The PCU will take care of it */ + if (lchan->type == GSM_LCHAN_PDTCH) + return 0; + + memset(&ulm, 0, sizeof(ulm)); + ulm.ta_offs_qbits = info_meas_ind->ta_offs_qbits; + ulm.ber10k = info_meas_ind->ber10k; + ulm.inv_rssi = info_meas_ind->inv_rssi; + + lchan_new_ul_meas(lchan, &ulm); + + return 0; +} + /* any L1 MPH_INFO indication prim recevied from bts model */ static int l1sap_mph_info_ind(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap, struct mph_info_param *info) @@ -165,6 +194,9 @@ static int l1sap_mph_info_ind(struct gsm_bts_trx *trx, case PRIM_INFO_TIME: rc = l1sap_info_time_ind(trx, l1sap, &info->u.time_ind); break; + case PRIM_INFO_MEAS: + rc = l1sap_info_meas_ind(trx, l1sap, &info->u.meas_ind); + break; default: LOGP(DL1P, LOGL_NOTICE, "unknown MPH_INFO ind type %d\n", info->type); diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index 14efc2c..38daa97 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -891,20 +891,20 @@ static void dump_meas_res(int ll, GsmL1_MeasParam_t *m) m->fBer, m->i16BurstTiming); } -static int process_meas_res(struct gsm_lchan *lchan, GsmL1_MeasParam_t *m) +static int process_meas_res(struct gsm_bts_trx *trx, uint8_t chan_nr, + GsmL1_MeasParam_t *m) { - struct bts_ul_meas ulm; - - /* in the GPRS case we are not interested in measurement - * processing. The PCU will take care of it */ - if (lchan->type == GSM_LCHAN_PDTCH) - return 0; - - ulm.ta_offs_qbits = m->i16BurstTiming; - ulm.ber10k = (unsigned int) (m->fBer * 100); - ulm.inv_rssi = (uint8_t) (m->fRssi * -1); + struct osmo_phsap_prim l1sap; + memset(&l1sap, 0, sizeof(l1sap)); + osmo_prim_init(&l1sap.oph, SAP_GSM_PH, PRIM_MPH_INFO, + PRIM_OP_INDICATION, NULL); + l1sap.u.info.type = PRIM_INFO_MEAS; + l1sap.u.info.u.meas_ind.chan_nr = chan_nr; + l1sap.u.info.u.meas_ind.ta_offs_qbits = m->i16BurstTiming; + l1sap.u.info.u.meas_ind.ber10k = (unsigned int) (m->fBer * 100); + l1sap.u.info.u.meas_ind.inv_rssi = (uint8_t) (m->fRssi * -1); - return lchan_new_ul_meas(lchan, &ulm); + return l1sap_up(trx, &l1sap); } static int handle_ph_data_ind(struct femtol1_hdl *fl1, GsmL1_PhDataInd_t *data_ind, @@ -940,7 +940,7 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1, GsmL1_PhDataInd_t *data_i fn = data_ind->u32Fn; link_id = (data_ind->sapi == GsmL1_Sapi_Sacch) ? 0x40 : 0x00; - process_meas_res(lchan, &data_ind->measParam); + process_meas_res(trx, chan_nr, &data_ind->measParam); if (data_ind->measParam.fLinkQuality < fl1->min_qual_norm && data_ind->msgUnitParam.u8Size != 0) { -- 2.1.0 --PMULwz+zIGJzpDN9--