From hfreyther at sysmocom.de Thu Jul 11 17:19:24 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Thu, 11 Jul 2013 19:19:24 +0200 Subject: Weird usage of gprs_ns_vty_init from gprs_bssgp_create In-Reply-To: <20130629083425.GU2836@nataraja.gnumonks.org> References: <20130626143747.GA16887@xiaoyu.lan> <51CD9718.3040403@eversberg.eu> <20130628145228.GG32145@nataraja.gnumonks.org> <20130629075512.GD23402@xiaoyu.lan> <20130629083425.GU2836@nataraja.gnumonks.org> Message-ID: <20130711171924.GA21884@xiaoyu.lan> On Sat, Jun 29, 2013 at 10:34:25AM +0200, Harald Welte wrote: Good Evening, > Ah, ok. I was (erroneously) assuming that the PCU would simply exit at > the time the connection to osmo-bts drops. This way, it re-spawns and > re-initializes nicely when the BTS is sending the next > PCU_IF_MSG_INFO_IND. However, I may be writing too much Erlang code in > recent days, hence my 'let it exit and re-spawn' attitude ;) ironically Harald and me were bitten by incomplete bssgp reset after the exit/restart of a bts/network. sysmocom would prefer if the PCU would fail/exit instead of an almost working reset. Currently a shell script and in the future systemd will relaunch the osmo-pcu process. I can prepare a patch that adds this behavior as VTY option unless everyone agrees that the process should exit. cheers holger -- - Holger Freyther http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Schivelbeiner Str. 5 * 10439 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From andreas at eversberg.eu Fri Jul 12 16:21:07 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Fri, 12 Jul 2013 18:21:07 +0200 Subject: Weird usage of gprs_ns_vty_init from gprs_bssgp_create In-Reply-To: <20130711171924.GA21884@xiaoyu.lan> References: <20130626143747.GA16887@xiaoyu.lan> <51CD9718.3040403@eversberg.eu> <20130628145228.GG32145@nataraja.gnumonks.org> <20130629075512.GD23402@xiaoyu.lan> <20130629083425.GU2836@nataraja.gnumonks.org> <20130711171924.GA21884@xiaoyu.lan> Message-ID: <51E02CF3.5000103@eversberg.eu> Holger Hans Peter Freyther wrote: > sysmocom would prefer if the PCU > would fail/exit instead of an almost working reset. i agree to have this exit case for more stable productive usage. still it should be an option. also i would like to know what is actually incomplete and how i can reproduce this bug. From holger at moiji-mobile.com Sat Jul 13 13:34:11 2013 From: holger at moiji-mobile.com (Holger Hans Peter Freyther) Date: Sat, 13 Jul 2013 15:34:11 +0200 Subject: [PATCH 1/2] misc: Remove if (timer_pending) stop_timer idiom from the code Message-ID: <1373722452-2868-1-git-send-email-holger@moiji-mobile.com> osmo_timer_del is an idempotent operation. There is no requirement to check if it is running. If you don't want a timer to run, delete it. Maybe one should have called the method _unschedule, _cancel to make this more clear. --- src/gprs_bssgp_pcu.cpp | 6 ++---- src/sysmo_sock.cpp | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index 54753b8..c791913 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -515,8 +515,7 @@ static int nsvc_signal_cb(unsigned int subsys, unsigned int signal, case S_NS_BLOCK: if (nsvc_unblocked) { nsvc_unblocked = 0; - if (osmo_timer_pending(&bvc_timer)) - osmo_timer_del(&bvc_timer); + osmo_timer_del(&bvc_timer); bvc_sig_reset = 0; bvc_reset = 0; bvc_unblocked = 0; @@ -646,8 +645,7 @@ void gprs_bssgp_destroy(void) if (!bssgp_nsi) return; - if (osmo_timer_pending(&bvc_timer)) - osmo_timer_del(&bvc_timer); + osmo_timer_del(&bvc_timer); osmo_signal_unregister_handler(SS_L_NS, nsvc_signal_cb, NULL); diff --git a/src/sysmo_sock.cpp b/src/sysmo_sock.cpp index a4cc6de..d4fb5a6 100644 --- a/src/sysmo_sock.cpp +++ b/src/sysmo_sock.cpp @@ -304,8 +304,7 @@ void pcu_l1if_close(void) if (!state) return; - if (osmo_timer_pending(&state->timer)) - osmo_timer_del(&state->timer); + osmo_timer_del(&state->timer); bfd = &state->conn_bfd; if (bfd->fd > 0) -- 1.8.3.2 From holger at moiji-mobile.com Sat Jul 13 13:34:12 2013 From: holger at moiji-mobile.com (Holger Hans Peter Freyther) Date: Sat, 13 Jul 2013 15:34:12 +0200 Subject: [PATCH 2/2] misc: Add an option exit/quit when the BSSGP is supposed to be destroyed In-Reply-To: <1373722452-2868-1-git-send-email-holger@moiji-mobile.com> References: <1373722452-2868-1-git-send-email-holger@moiji-mobile.com> Message-ID: <1373722452-2868-2-git-send-email-holger@moiji-mobile.com> The PCU does not properly re-set the state when the connection to the BTS is lost (and the SGSN potentially is re-started during that). This results in the BSSGP BVCI > 1 remaining blocked and no data will be accepted by the SGSN. Add the '-e' option and exit the PCU when the BSSGP/NS are getting destroyed. --- src/gprs_bssgp_pcu.cpp | 13 ++++++++++++- src/gprs_bssgp_pcu.h | 3 ++- src/openbts_sock.cpp | 2 +- src/pcu_l1_if.cpp | 2 +- src/pcu_main.cpp | 7 ++++++- src/sysmo_sock.cpp | 2 +- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index c791913..59185e3 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -27,6 +27,7 @@ struct bssgp_bvc_ctx *bctx = NULL; struct gprs_nsvc *nsvc = NULL; static int bvc_sig_reset = 0, bvc_reset = 0, bvc_unblocked = 0; extern uint16_t spoof_mcc, spoof_mnc; +static int exit_on_destroy = 0; struct osmo_timer_list bvc_timer; @@ -640,8 +641,13 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, return 0; } -void gprs_bssgp_destroy(void) +void gprs_bssgp_destroy_or_exit(void) { + if (exit_on_destroy) { + LOGP(DBSSGP, LOGL_NOTICE, "Exiting on BSSGP destruction.\n"); + exit(0); + } + if (!bssgp_nsi) return; @@ -662,3 +668,8 @@ void gprs_bssgp_destroy(void) bssgp_nsi = NULL; } +void gprs_bssgp_exit_on_destroy(void) +{ + LOGP(DBSSGP, LOGL_NOTICE, "Going to quit on BSSGP destruction\n"); + exit_on_destroy = 1; +} diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h index d669c3a..dc57e4f 100644 --- a/src/gprs_bssgp_pcu.h +++ b/src/gprs_bssgp_pcu.h @@ -56,6 +56,7 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, uint16_t uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac, uint16_t cell_id); -void gprs_bssgp_destroy(void); +void gprs_bssgp_exit_on_destroy(void); +void gprs_bssgp_destroy_or_exit(void); #endif // GPRS_BSSGP_PCU_H diff --git a/src/openbts_sock.cpp b/src/openbts_sock.cpp index 845aa77..a09f834 100644 --- a/src/openbts_sock.cpp +++ b/src/openbts_sock.cpp @@ -179,7 +179,7 @@ int pcu_l1if_open() void pcu_l1if_close(void) { - gprs_bssgp_destroy(); + gprs_bssgp_destroy_or_exit(); /* FIXME: cleanup l1if */ talloc_free(l1fh->fl1h); diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 923070f..037cf60 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -369,7 +369,7 @@ bssgp_failed: trx, ts); } } - gprs_bssgp_destroy(); + gprs_bssgp_destroy_or_exit(); return 0; } LOGP(DL1IF, LOGL_INFO, "BTS available\n"); diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp index 041831f6..754043f 100644 --- a/src/pcu_main.cpp +++ b/src/pcu_main.cpp @@ -60,6 +60,7 @@ static void print_help() "provided by BTS\n" " -r --realtime PRIO Use SCHED_RR with the specified " "priority\n" + " -e --exit Exit the application on disconnect\n" ); } @@ -75,10 +76,11 @@ static void handle_options(int argc, char **argv) { "mnc", 1, 0, 'n' }, { "version", 0, 0, 'V' }, { "realtime", 1, 0, 'r' }, + { "exit", 0, 0, 'e' }, { 0, 0, 0, 0 } }; - c = getopt_long(argc, argv, "hc:m:n:Vr:", + c = getopt_long(argc, argv, "hc:m:n:Vr:e", long_options, &option_idx); if (c == -1) break; @@ -105,6 +107,9 @@ static void handle_options(int argc, char **argv) case 'r': rt_prio = atoi(optarg); break; + case 'e': + gprs_bssgp_exit_on_destroy(); + break; default: fprintf(stderr, "Unknown option '%c'\n", c); exit(0); diff --git a/src/sysmo_sock.cpp b/src/sysmo_sock.cpp index d4fb5a6..e116e5a 100644 --- a/src/sysmo_sock.cpp +++ b/src/sysmo_sock.cpp @@ -117,7 +117,7 @@ static void pcu_sock_close(struct pcu_sock_state *state, int lost) } } - gprs_bssgp_destroy(); + gprs_bssgp_destroy_or_exit(); if (lost) { state->timer.cb = pcu_sock_timeout; -- 1.8.3.2 From Ivan.Kluchnikov at fairwaves.ru Thu Jul 25 16:27:04 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Thu, 25 Jul 2013 20:27:04 +0400 Subject: [PATCH 2/2] misc: Add an option exit/quit when the BSSGP is supposed to be destroyed In-Reply-To: <1373722452-2868-2-git-send-email-holger@moiji-mobile.com> References: <1373722452-2868-1-git-send-email-holger@moiji-mobile.com> <1373722452-2868-2-git-send-email-holger@moiji-mobile.com> Message-ID: Hi Holger, Sorry for slow response. Actually I think that we should implement more intellectual behavior of PCUfor handling restarts and disconnections of BTS and SGSN. I should try to find the way to solve this problem, but I will commit this patch, because it fixes current problems. 2013/7/13 Holger Hans Peter Freyther > The PCU does not properly re-set the state when the connection to the > BTS is lost (and the SGSN potentially is re-started during that). This > results in the BSSGP BVCI > 1 remaining blocked and no data will be > accepted by the SGSN. > > Add the '-e' option and exit the PCU when the BSSGP/NS are getting > destroyed. > --- > src/gprs_bssgp_pcu.cpp | 13 ++++++++++++- > src/gprs_bssgp_pcu.h | 3 ++- > src/openbts_sock.cpp | 2 +- > src/pcu_l1_if.cpp | 2 +- > src/pcu_main.cpp | 7 ++++++- > src/sysmo_sock.cpp | 2 +- > 6 files changed, 23 insertions(+), 6 deletions(-) > > diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp > index c791913..59185e3 100644 > --- a/src/gprs_bssgp_pcu.cpp > +++ b/src/gprs_bssgp_pcu.cpp > @@ -27,6 +27,7 @@ struct bssgp_bvc_ctx *bctx = NULL; > struct gprs_nsvc *nsvc = NULL; > static int bvc_sig_reset = 0, bvc_reset = 0, bvc_unblocked = 0; > extern uint16_t spoof_mcc, spoof_mnc; > +static int exit_on_destroy = 0; > > struct osmo_timer_list bvc_timer; > > @@ -640,8 +641,13 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t > sgsn_ip, > return 0; > } > > -void gprs_bssgp_destroy(void) > +void gprs_bssgp_destroy_or_exit(void) > { > + if (exit_on_destroy) { > + LOGP(DBSSGP, LOGL_NOTICE, "Exiting on BSSGP > destruction.\n"); > + exit(0); > + } > + > if (!bssgp_nsi) > return; > > @@ -662,3 +668,8 @@ void gprs_bssgp_destroy(void) > bssgp_nsi = NULL; > } > > +void gprs_bssgp_exit_on_destroy(void) > +{ > + LOGP(DBSSGP, LOGL_NOTICE, "Going to quit on BSSGP destruction\n"); > + exit_on_destroy = 1; > +} > diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h > index d669c3a..dc57e4f 100644 > --- a/src/gprs_bssgp_pcu.h > +++ b/src/gprs_bssgp_pcu.h > @@ -56,6 +56,7 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t > sgsn_ip, uint16_t > uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac, > uint16_t cell_id); > > -void gprs_bssgp_destroy(void); > +void gprs_bssgp_exit_on_destroy(void); > +void gprs_bssgp_destroy_or_exit(void); > > #endif // GPRS_BSSGP_PCU_H > diff --git a/src/openbts_sock.cpp b/src/openbts_sock.cpp > index 845aa77..a09f834 100644 > --- a/src/openbts_sock.cpp > +++ b/src/openbts_sock.cpp > @@ -179,7 +179,7 @@ int pcu_l1if_open() > > void pcu_l1if_close(void) > { > - gprs_bssgp_destroy(); > + gprs_bssgp_destroy_or_exit(); > > /* FIXME: cleanup l1if */ > talloc_free(l1fh->fl1h); > diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp > index 923070f..037cf60 100644 > --- a/src/pcu_l1_if.cpp > +++ b/src/pcu_l1_if.cpp > @@ -369,7 +369,7 @@ bssgp_failed: > trx, ts); > } > } > - gprs_bssgp_destroy(); > + gprs_bssgp_destroy_or_exit(); > return 0; > } > LOGP(DL1IF, LOGL_INFO, "BTS available\n"); > diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp > index 041831f6..754043f 100644 > --- a/src/pcu_main.cpp > +++ b/src/pcu_main.cpp > @@ -60,6 +60,7 @@ static void print_help() > "provided by BTS\n" > " -r --realtime PRIO Use SCHED_RR with the specified " > "priority\n" > + " -e --exit Exit the application on > disconnect\n" > ); > } > > @@ -75,10 +76,11 @@ static void handle_options(int argc, char **argv) > { "mnc", 1, 0, 'n' }, > { "version", 0, 0, 'V' }, > { "realtime", 1, 0, 'r' }, > + { "exit", 0, 0, 'e' }, > { 0, 0, 0, 0 } > }; > > - c = getopt_long(argc, argv, "hc:m:n:Vr:", > + c = getopt_long(argc, argv, "hc:m:n:Vr:e", > long_options, &option_idx); > if (c == -1) > break; > @@ -105,6 +107,9 @@ static void handle_options(int argc, char **argv) > case 'r': > rt_prio = atoi(optarg); > break; > + case 'e': > + gprs_bssgp_exit_on_destroy(); > + break; > default: > fprintf(stderr, "Unknown option '%c'\n", c); > exit(0); > diff --git a/src/sysmo_sock.cpp b/src/sysmo_sock.cpp > index d4fb5a6..e116e5a 100644 > --- a/src/sysmo_sock.cpp > +++ b/src/sysmo_sock.cpp > @@ -117,7 +117,7 @@ static void pcu_sock_close(struct pcu_sock_state > *state, int lost) > } > } > > - gprs_bssgp_destroy(); > + gprs_bssgp_destroy_or_exit(); > > if (lost) { > state->timer.cb = pcu_sock_timeout; > -- > 1.8.3.2 > > > -- Regards, Ivan Kluchnikov. http://fairwaves.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: From hfreyther at sysmocom.de Fri Jul 26 04:31:50 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Fri, 26 Jul 2013 06:31:50 +0200 Subject: [PATCH 2/2] misc: Add an option exit/quit when the BSSGP is supposed to be destroyed In-Reply-To: References: <1373722452-2868-1-git-send-email-holger@moiji-mobile.com> <1373722452-2868-2-git-send-email-holger@moiji-mobile.com> Message-ID: <20130726043150.GB2673@xiaoyu.lan> On Thu, Jul 25, 2013 at 08:27:04PM +0400, Ivan Kluchnikov wrote: Dear Ivan, > I should try to find the way to solve this problem, but I will commit this > patch, because it fixes current problems. Well, I have more commits pending for review but I would like to get the first bits in first instead of sending you a patch bomb. The 'root' cause appears to be that the state is in a couple of static fields that are throughout the file. I started to move them into a struct (an organic cell/entity). At that point it became clear of why NS/BSSGP is behaving like it does behave. Once you merge the two changes, I will rebase and sent my cleanup patchset. And then we can look into properly re-setting the state. kind regards holger -- - Holger Freyther http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Schivelbeiner Str. 5 * 10439 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From hfreyther at sysmocom.de Sat Jul 27 20:20:48 2013 From: hfreyther at sysmocom.de (Holger Freyther) Date: Sat, 27 Jul 2013 22:20:48 +0200 Subject: [PATCH 2/8] misc: Move the struct bssgp_bvc_ctx into the struct osmo_pcu In-Reply-To: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1374956454-26827-2-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther --- src/gprs_bssgp_pcu.cpp | 47 ++++++++++++++++++++++++++--------------------- src/gprs_bssgp_pcu.h | 4 ++-- src/gprs_rlcmac.cpp | 1 + src/gprs_rlcmac_data.cpp | 3 ++- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index e94b5eb..2b5068e 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -23,6 +23,7 @@ struct osmo_pcu { struct gprs_nsvc *nsvc; + struct bssgp_bvc_ctx *bctx; int bvc_sig_reset; int bvc_reset; @@ -34,7 +35,6 @@ static struct osmo_pcu the_pcu = { 0, }; struct sgsn_instance *sgsn; extern void *tall_pcu_ctx; -struct bssgp_bvc_ctx *bctx = NULL; extern uint16_t spoof_mcc, spoof_mnc; struct osmo_timer_list bvc_timer; @@ -538,12 +538,12 @@ static int nsvc_signal_cb(unsigned int subsys, unsigned int signal, int gprs_bssgp_tx_fc_bvc(void) { - if (!bctx) { + if (!the_pcu.bctx) { LOGP(DBSSGP, LOGL_ERROR, "No bctx\n"); return -EIO; } /* FIXME: use real values */ - return bssgp_tx_fc_bvc(bctx, 1, 6553500, 819100, 50000, 50000, + return bssgp_tx_fc_bvc(the_pcu.bctx, 1, 6553500, 819100, 50000, 50000, NULL, NULL); // return bssgp_tx_fc_bvc(bctx, 1, 84000, 25000, 48000, 45000, // NULL, NULL); @@ -555,29 +555,29 @@ static void bvc_timeout(void *_priv) if (!the_pcu.bvc_sig_reset) { LOGP(DBSSGP, LOGL_INFO, "Sending reset on BVCI 0\n"); - bssgp_tx_bvc_reset(bctx, 0, BSSGP_CAUSE_OML_INTERV); + bssgp_tx_bvc_reset(the_pcu.bctx, 0, BSSGP_CAUSE_OML_INTERV); osmo_timer_schedule(&bvc_timer, 1, 0); return; } if (!the_pcu.bvc_reset) { LOGP(DBSSGP, LOGL_INFO, "Sending reset on BVCI %d\n", - bctx->bvci); - bssgp_tx_bvc_reset(bctx, bctx->bvci, BSSGP_CAUSE_OML_INTERV); + the_pcu.bctx->bvci); + bssgp_tx_bvc_reset(the_pcu.bctx, the_pcu.bctx->bvci, BSSGP_CAUSE_OML_INTERV); osmo_timer_schedule(&bvc_timer, 1, 0); return; } if (!the_pcu.bvc_unblocked) { LOGP(DBSSGP, LOGL_INFO, "Sending unblock on BVCI %d\n", - bctx->bvci); - bssgp_tx_bvc_unblock(bctx); + the_pcu.bctx->bvci); + bssgp_tx_bvc_unblock(the_pcu.bctx); osmo_timer_schedule(&bvc_timer, 1, 0); return; } LOGP(DBSSGP, LOGL_DEBUG, "Sending flow control info on BVCI %d\n", - bctx->bvci); + the_pcu.bctx->bvci); gprs_bssgp_tx_fc_bvc(); osmo_timer_schedule(&bvc_timer, bts->fc_interval, 0); } @@ -595,7 +595,7 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, mnc = ((mnc & 0xf00) >> 8) * 100 + ((mnc & 0x0f0) >> 4) * 10 + (mnc & 0x00f); cell_id = ntohs(cell_id); - if (bctx) + if (the_pcu.bctx) return 0; /* if already created, must return 0: no error */ bssgp_nsi = gprs_ns_instantiate(&sgsn_ns_cb, tall_pcu_ctx); @@ -625,23 +625,23 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, return -EINVAL; } - bctx = btsctx_alloc(bvci, nsei); - if (!bctx) { + the_pcu.bctx = btsctx_alloc(bvci, nsei); + if (!the_pcu.bctx) { LOGP(DBSSGP, LOGL_ERROR, "Failed to create BSSGP context\n"); the_pcu.nsvc = NULL; gprs_ns_destroy(bssgp_nsi); bssgp_nsi = NULL; return -EINVAL; } - bctx->ra_id.mcc = spoof_mcc ? : mcc; - bctx->ra_id.mnc = spoof_mnc ? : mnc; - bctx->ra_id.lac = lac; - bctx->ra_id.rac = rac; - bctx->cell_id = cell_id; + the_pcu.bctx->ra_id.mcc = spoof_mcc ? : mcc; + the_pcu.bctx->ra_id.mnc = spoof_mnc ? : mnc; + the_pcu.bctx->ra_id.lac = lac; + the_pcu.bctx->ra_id.rac = rac; + the_pcu.bctx->cell_id = cell_id; osmo_signal_register_handler(SS_L_NS, nsvc_signal_cb, NULL); -// bssgp_tx_bvc_reset(bctx, bctx->bvci, BSSGP_CAUSE_PROTO_ERR_UNSPEC); +// bssgp_tx_bvc_reset(the_pcu.bctx, the_pcu.bctx->bvci, BSSGP_CAUSE_PROTO_ERR_UNSPEC); bvc_timer.cb = bvc_timeout; @@ -666,9 +666,9 @@ void gprs_bssgp_destroy_or_exit(void) the_pcu.nsvc = NULL; /* FIXME: move this to libgb: btsctx_free() */ - llist_del(&bctx->list); - talloc_free(bctx); - bctx = NULL; + llist_del(&the_pcu.bctx->list); + talloc_free(the_pcu.bctx); + the_pcu.bctx = NULL; /* FIXME: blocking... */ @@ -681,3 +681,8 @@ void gprs_bssgp_exit_on_destroy(void) LOGP(DBSSGP, LOGL_NOTICE, "Going to quit on BSSGP destruction\n"); the_pcu.exit_on_destroy = 1; } + +struct bssgp_bvc_ctx *gprs_bssgp_pcu_current_bctx(void) +{ + return the_pcu.bctx; +} diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h index dc57e4f..dff86a3 100644 --- a/src/gprs_bssgp_pcu.h +++ b/src/gprs_bssgp_pcu.h @@ -41,8 +41,6 @@ struct bssgp_bvc_ctx *btsctx_alloc(uint16_t bvci, uint16_t nsei); #define NS_HDR_LEN 4 #define IE_LLC_PDU 14 -extern struct bssgp_bvc_ctx *bctx; - int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp); int gprs_bssgp_pcu_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, struct bssgp_bvc_ctx *bctx); @@ -59,4 +57,6 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, uint16_t void gprs_bssgp_exit_on_destroy(void); void gprs_bssgp_destroy_or_exit(void); +struct bssgp_bvc_ctx *gprs_bssgp_pcu_current_bctx(void); + #endif // GPRS_BSSGP_PCU_H diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp index 2ea0a61..f3a24f7 100644 --- a/src/gprs_rlcmac.cpp +++ b/src/gprs_rlcmac.cpp @@ -1789,6 +1789,7 @@ int gprs_rlcmac_tx_ul_ud(gprs_rlcmac_tbf *tbf) uint8_t qos_profile[3]; struct msgb *llc_pdu; unsigned msg_len = NS_HDR_LEN + BSSGP_HDR_LEN + tbf->llc_index; + struct bssgp_bvc_ctx *bctx = gprs_bssgp_pcu_current_bctx(); LOGP(DBSSGP, LOGL_INFO, "LLC [PCU -> SGSN] TFI: %u TLLI: 0x%08x len=%d\n", tbf->tfi, tbf->tlli, tbf->llc_index); if (!bctx) { diff --git a/src/gprs_rlcmac_data.cpp b/src/gprs_rlcmac_data.cpp index 4f2b649..99fac1b 100644 --- a/src/gprs_rlcmac_data.cpp +++ b/src/gprs_rlcmac_data.cpp @@ -1253,7 +1253,8 @@ static struct msgb *llc_dequeue(struct gprs_rlcmac_tbf *tbf) frames = 0xff; if (octets > 0xffffff) octets = 0xffffff; - bssgp_tx_llc_discarded(bctx, tbf->tlli, frames, octets); + bssgp_tx_llc_discarded(gprs_bssgp_pcu_current_bctx(), + tbf->tlli, frames, octets); } return msg; -- 1.8.3.2 From hfreyther at sysmocom.de Sat Jul 27 20:20:49 2013 From: hfreyther at sysmocom.de (Holger Freyther) Date: Sat, 27 Jul 2013 22:20:49 +0200 Subject: [PATCH 3/8] misc: Remove the unused sgsn pointer from the compilation unit In-Reply-To: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1374956454-26827-3-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther --- src/gprs_bssgp_pcu.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index 2b5068e..66c4cb7 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -33,7 +33,6 @@ struct osmo_pcu { static struct osmo_pcu the_pcu = { 0, }; -struct sgsn_instance *sgsn; extern void *tall_pcu_ctx; extern uint16_t spoof_mcc, spoof_mnc; -- 1.8.3.2 From hfreyther at sysmocom.de Sat Jul 27 20:20:50 2013 From: hfreyther at sysmocom.de (Holger Freyther) Date: Sat, 27 Jul 2013 22:20:50 +0200 Subject: [PATCH 4/8] misc: Move the bvc_timer into the struct osmo_pcu In-Reply-To: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1374956454-26827-4-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther This continues with the previous changes to reduce the global state. --- src/gprs_bssgp_pcu.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index 66c4cb7..8c68bf6 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -25,6 +25,8 @@ struct osmo_pcu { struct gprs_nsvc *nsvc; struct bssgp_bvc_ctx *bctx; + struct osmo_timer_list bvc_timer; + int bvc_sig_reset; int bvc_reset; int bvc_unblocked; @@ -36,8 +38,6 @@ static struct osmo_pcu the_pcu = { 0, }; extern void *tall_pcu_ctx; extern uint16_t spoof_mcc, spoof_mnc; -struct osmo_timer_list bvc_timer; - static void bvc_timeout(void *_priv); static int parse_imsi(struct tlv_parsed *tp, char *imsi) @@ -523,7 +523,7 @@ static int nsvc_signal_cb(unsigned int subsys, unsigned int signal, case S_NS_BLOCK: if (nsvc_unblocked) { nsvc_unblocked = 0; - osmo_timer_del(&bvc_timer); + osmo_timer_del(&the_pcu.bvc_timer); the_pcu.bvc_sig_reset = 0; the_pcu.bvc_reset = 0; the_pcu.bvc_unblocked = 0; @@ -555,7 +555,7 @@ static void bvc_timeout(void *_priv) if (!the_pcu.bvc_sig_reset) { LOGP(DBSSGP, LOGL_INFO, "Sending reset on BVCI 0\n"); bssgp_tx_bvc_reset(the_pcu.bctx, 0, BSSGP_CAUSE_OML_INTERV); - osmo_timer_schedule(&bvc_timer, 1, 0); + osmo_timer_schedule(&the_pcu.bvc_timer, 1, 0); return; } @@ -563,7 +563,7 @@ static void bvc_timeout(void *_priv) LOGP(DBSSGP, LOGL_INFO, "Sending reset on BVCI %d\n", the_pcu.bctx->bvci); bssgp_tx_bvc_reset(the_pcu.bctx, the_pcu.bctx->bvci, BSSGP_CAUSE_OML_INTERV); - osmo_timer_schedule(&bvc_timer, 1, 0); + osmo_timer_schedule(&the_pcu.bvc_timer, 1, 0); return; } @@ -571,14 +571,14 @@ static void bvc_timeout(void *_priv) LOGP(DBSSGP, LOGL_INFO, "Sending unblock on BVCI %d\n", the_pcu.bctx->bvci); bssgp_tx_bvc_unblock(the_pcu.bctx); - osmo_timer_schedule(&bvc_timer, 1, 0); + osmo_timer_schedule(&the_pcu.bvc_timer, 1, 0); return; } LOGP(DBSSGP, LOGL_DEBUG, "Sending flow control info on BVCI %d\n", the_pcu.bctx->bvci); gprs_bssgp_tx_fc_bvc(); - osmo_timer_schedule(&bvc_timer, bts->fc_interval, 0); + osmo_timer_schedule(&the_pcu.bvc_timer, bts->fc_interval, 0); } /* create BSSGP/NS layer instances */ @@ -642,7 +642,7 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, // bssgp_tx_bvc_reset(the_pcu.bctx, the_pcu.bctx->bvci, BSSGP_CAUSE_PROTO_ERR_UNSPEC); - bvc_timer.cb = bvc_timeout; + the_pcu.bvc_timer.cb = bvc_timeout; return 0; @@ -658,7 +658,7 @@ void gprs_bssgp_destroy_or_exit(void) if (!bssgp_nsi) return; - osmo_timer_del(&bvc_timer); + osmo_timer_del(&the_pcu.bvc_timer); osmo_signal_unregister_handler(SS_L_NS, nsvc_signal_cb, NULL); -- 1.8.3.2 From hfreyther at sysmocom.de Sat Jul 27 20:20:52 2013 From: hfreyther at sysmocom.de (Holger Freyther) Date: Sat, 27 Jul 2013 22:20:52 +0200 Subject: [PATCH 6/8] bssgp: Reset the BVC and NSVC state in the destroy routine In-Reply-To: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1374956454-26827-6-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther This might explain the issue of the BVCI > 1 not being unblocked as the internal state has not been re-set when destroying the bssgp. --- src/gprs_bssgp_pcu.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index edb088c..2e93a02 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -671,6 +671,10 @@ void gprs_bssgp_destroy_or_exit(void) the_pcu.bctx = NULL; /* FIXME: blocking... */ + the_pcu.nsvc_unblocked = 0; + the_pcu.bvc_sig_reset = 0; + the_pcu.bvc_reset = 0; + the_pcu.bvc_unblocked = 0; gprs_ns_destroy(bssgp_nsi); bssgp_nsi = NULL; -- 1.8.3.2 From hfreyther at sysmocom.de Sat Jul 27 20:20:54 2013 From: hfreyther at sysmocom.de (Holger Freyther) Date: Sat, 27 Jul 2013 22:20:54 +0200 Subject: [PATCH 8/8] misc: Move the parsing of the ms_class from RA Capabilities to a method In-Reply-To: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1374956454-26827-8-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther Decrease the number of lines of a single method by splitting things up. The fewer lines of code, branches and side-effects in a method, the easier it will be to understand. The other benefit is that one can start creating unit tests for the some parts of the code. --- src/gprs_bssgp_pcu.cpp | 75 +++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index b90f2c5..e994f9f 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -71,6 +71,47 @@ static int parse_imsi(struct tlv_parsed *tp, char *imsi) return 0; } +static int parse_ra_cap_ms_class(struct tlv_parsed *tp) +{ + bitvec *block; + unsigned rp = 0; + uint8_t ms_class = 0; + uint8_t cap_len; + uint8_t *cap; + + if (!TLVP_PRESENT(tp, BSSGP_IE_MS_RADIO_ACCESS_CAP)) + return ms_class; + + cap_len = TLVP_LEN(tp, BSSGP_IE_MS_RADIO_ACCESS_CAP); + cap = (uint8_t *) TLVP_VAL(tp, BSSGP_IE_MS_RADIO_ACCESS_CAP); + + block = bitvec_alloc(cap_len); + bitvec_unpack(block, cap); + bitvec_read_field(block, rp, 4); // Access Technology Type + bitvec_read_field(block, rp, 7); // Length of Access Capabilities + bitvec_read_field(block, rp, 3); // RF Power Capability + if (bitvec_read_field(block, rp, 1)) // A5 Bits Present + bitvec_read_field(block, rp, 7); // A5 Bits + bitvec_read_field(block, rp, 1); // ES IND + bitvec_read_field(block, rp, 1); // PS + bitvec_read_field(block, rp, 1); // VGCS + bitvec_read_field(block, rp, 1); // VBS + if (bitvec_read_field(block, rp, 1)) { // Multislot Cap Present + if (bitvec_read_field(block, rp, 1)) // HSCSD Present + bitvec_read_field(block, rp, 5); // Class + if (bitvec_read_field(block, rp, 1)) { // GPRS Present + ms_class = bitvec_read_field(block, rp, 5); // Class + bitvec_read_field(block, rp, 1); // Ext. + } + if (bitvec_read_field(block, rp, 1)) // SMS Present + bitvec_read_field(block, rp, 4); // SMS Value + bitvec_read_field(block, rp, 4); // SMS Value + } + + bitvec_free(block); + return ms_class; +} + int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp) { struct bssgp_ud_hdr *budh; @@ -107,38 +148,8 @@ int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp) parse_imsi(tp, imsi); /* parse ms radio access capability */ - uint8_t ms_class = 0; - if (TLVP_PRESENT(tp, BSSGP_IE_MS_RADIO_ACCESS_CAP)) - { - bitvec *block; - uint8_t cap_len = TLVP_LEN(tp, BSSGP_IE_MS_RADIO_ACCESS_CAP); - uint8_t *cap = (uint8_t *) TLVP_VAL(tp, BSSGP_IE_MS_RADIO_ACCESS_CAP); - unsigned rp = 0; - - block = bitvec_alloc(cap_len); - bitvec_unpack(block, cap); - bitvec_read_field(block, rp, 4); // Access Technology Type - bitvec_read_field(block, rp, 7); // Length of Access Capabilities - bitvec_read_field(block, rp, 3); // RF Power Capability - if (bitvec_read_field(block, rp, 1)) // A5 Bits Present - bitvec_read_field(block, rp, 7); // A5 Bits - bitvec_read_field(block, rp, 1); // ES IND - bitvec_read_field(block, rp, 1); // PS - bitvec_read_field(block, rp, 1); // VGCS - bitvec_read_field(block, rp, 1); // VBS - if (bitvec_read_field(block, rp, 1)) { // Multislot Cap Present - if (bitvec_read_field(block, rp, 1)) // HSCSD Present - bitvec_read_field(block, rp, 5); // Class - if (bitvec_read_field(block, rp, 1)) { // GPRS Present - ms_class = bitvec_read_field(block, rp, 5); // Class - bitvec_read_field(block, rp, 1); // Ext. - } - if (bitvec_read_field(block, rp, 1)) // SMS Present - bitvec_read_field(block, rp, 4); // SMS Value - bitvec_read_field(block, rp, 4); // SMS Value - } - bitvec_free(block); - } + uint8_t ms_class = parse_ra_cap_ms_class(tp); + /* get lifetime */ uint16_t delay_csec = 0xffff; if (TLVP_PRESENT(tp, BSSGP_IE_PDU_LIFETIME)) -- 1.8.3.2 From hfreyther at sysmocom.de Sat Jul 27 20:20:51 2013 From: hfreyther at sysmocom.de (Holger Freyther) Date: Sat, 27 Jul 2013 22:20:51 +0200 Subject: [PATCH 5/8] misc: Move the nsvc_unblocked into the struct osmo_pcu In-Reply-To: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1374956454-26827-5-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther --- src/gprs_bssgp_pcu.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index 8c68bf6..edb088c 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -27,6 +27,8 @@ struct osmo_pcu { struct osmo_timer_list bvc_timer; + int nsvc_unblocked; + int bvc_sig_reset; int bvc_reset; int bvc_unblocked; @@ -492,7 +494,6 @@ static int sgsn_ns_cb(enum gprs_ns_evt event, struct gprs_nsvc *nsvc, struct msg return rc; } -static int nsvc_unblocked = 0; static int nsvc_signal_cb(unsigned int subsys, unsigned int signal, void *handler_data, void *signal_data) @@ -510,8 +511,8 @@ static int nsvc_signal_cb(unsigned int subsys, unsigned int signal, switch (signal) { case S_NS_UNBLOCK: - if (!nsvc_unblocked) { - nsvc_unblocked = 1; + if (!the_pcu.nsvc_unblocked) { + the_pcu.nsvc_unblocked = 1; LOGP(DPCU, LOGL_NOTICE, "NS-VC %d is unblocked.\n", the_pcu.nsvc->nsvci); the_pcu.bvc_sig_reset = 0; @@ -521,8 +522,8 @@ static int nsvc_signal_cb(unsigned int subsys, unsigned int signal, } break; case S_NS_BLOCK: - if (nsvc_unblocked) { - nsvc_unblocked = 0; + if (the_pcu.nsvc_unblocked) { + the_pcu.nsvc_unblocked = 0; osmo_timer_del(&the_pcu.bvc_timer); the_pcu.bvc_sig_reset = 0; the_pcu.bvc_reset = 0; -- 1.8.3.2 From hfreyther at sysmocom.de Sat Jul 27 20:20:47 2013 From: hfreyther at sysmocom.de (Holger Freyther) Date: Sat, 27 Jul 2013 22:20:47 +0200 Subject: [PATCH 1/8] misc: Introduce a struct osmo_pcu and move things into it. Message-ID: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther One of the issues with not properly re-setting everything is that due the global state it is not clear which variables belong together and how long it exists. Begin with creating a osmo_pcu and moving things into this class. Think of an organic cell, this commit is introducing the cell wall around it... and defines what is inside and what is outside of it. --- src/gprs_bssgp_pcu.cpp | 56 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index 59185e3..e94b5eb 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -21,13 +21,21 @@ #include #include +struct osmo_pcu { + struct gprs_nsvc *nsvc; + + int bvc_sig_reset; + int bvc_reset; + int bvc_unblocked; + int exit_on_destroy; +}; + +static struct osmo_pcu the_pcu = { 0, }; + struct sgsn_instance *sgsn; extern void *tall_pcu_ctx; struct bssgp_bvc_ctx *bctx = NULL; -struct gprs_nsvc *nsvc = NULL; -static int bvc_sig_reset = 0, bvc_reset = 0, bvc_unblocked = 0; extern uint16_t spoof_mcc, spoof_mnc; -static int exit_on_destroy = 0; struct osmo_timer_list bvc_timer; @@ -353,10 +361,10 @@ int gprs_bssgp_pcu_rx_sign(struct msgb *msg, struct tlv_parsed *tp, struct bssgp break; case BSSGP_PDUT_BVC_RESET_ACK: LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_BVC_RESET_ACK\n"); - if (!bvc_sig_reset) - bvc_sig_reset = 1; + if (!the_pcu.bvc_sig_reset) + the_pcu.bvc_sig_reset = 1; else - bvc_reset = 1; + the_pcu.bvc_reset = 1; bvc_timeout(NULL); break; case BSSGP_PDUT_PAGING_PS: @@ -380,7 +388,7 @@ int gprs_bssgp_pcu_rx_sign(struct msgb *msg, struct tlv_parsed *tp, struct bssgp break; case BSSGP_PDUT_BVC_UNBLOCK_ACK: LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_BVC_UNBLOCK_ACK\n"); - bvc_unblocked = 1; + the_pcu.bvc_unblocked = 1; bvc_timeout(NULL); break; case BSSGP_PDUT_SGSN_INVOKE_TRACE: @@ -496,7 +504,7 @@ static int nsvc_signal_cb(unsigned int subsys, unsigned int signal, return -EINVAL; nssd = (struct ns_signal_data *)signal_data; - if (nssd->nsvc != nsvc) { + if (nssd->nsvc != the_pcu.nsvc) { LOGP(DPCU, LOGL_ERROR, "Signal received of unknown NSVC\n"); return -EINVAL; } @@ -506,10 +514,10 @@ static int nsvc_signal_cb(unsigned int subsys, unsigned int signal, if (!nsvc_unblocked) { nsvc_unblocked = 1; LOGP(DPCU, LOGL_NOTICE, "NS-VC %d is unblocked.\n", - nsvc->nsvci); - bvc_sig_reset = 0; - bvc_reset = 0; - bvc_unblocked = 0; + the_pcu.nsvc->nsvci); + the_pcu.bvc_sig_reset = 0; + the_pcu.bvc_reset = 0; + the_pcu.bvc_unblocked = 0; bvc_timeout(NULL); } break; @@ -517,9 +525,9 @@ static int nsvc_signal_cb(unsigned int subsys, unsigned int signal, if (nsvc_unblocked) { nsvc_unblocked = 0; osmo_timer_del(&bvc_timer); - bvc_sig_reset = 0; - bvc_reset = 0; - bvc_unblocked = 0; + the_pcu.bvc_sig_reset = 0; + the_pcu.bvc_reset = 0; + the_pcu.bvc_unblocked = 0; LOGP(DPCU, LOGL_NOTICE, "NS-VC is blocked.\n"); } break; @@ -545,14 +553,14 @@ static void bvc_timeout(void *_priv) { struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts; - if (!bvc_sig_reset) { + if (!the_pcu.bvc_sig_reset) { LOGP(DBSSGP, LOGL_INFO, "Sending reset on BVCI 0\n"); bssgp_tx_bvc_reset(bctx, 0, BSSGP_CAUSE_OML_INTERV); osmo_timer_schedule(&bvc_timer, 1, 0); return; } - if (!bvc_reset) { + if (!the_pcu.bvc_reset) { LOGP(DBSSGP, LOGL_INFO, "Sending reset on BVCI %d\n", bctx->bvci); bssgp_tx_bvc_reset(bctx, bctx->bvci, BSSGP_CAUSE_OML_INTERV); @@ -560,7 +568,7 @@ static void bvc_timeout(void *_priv) return; } - if (!bvc_unblocked) { + if (!the_pcu.bvc_unblocked) { LOGP(DBSSGP, LOGL_INFO, "Sending unblock on BVCI %d\n", bctx->bvci); bssgp_tx_bvc_unblock(bctx); @@ -609,8 +617,8 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, dest.sin_port = htons(sgsn_port); dest.sin_addr.s_addr = htonl(sgsn_ip); - nsvc = gprs_ns_nsip_connect(bssgp_nsi, &dest, nsei, nsvci); - if (!nsvc) { + the_pcu.nsvc = gprs_ns_nsip_connect(bssgp_nsi, &dest, nsei, nsvci); + if (!the_pcu.nsvc) { LOGP(DBSSGP, LOGL_ERROR, "Failed to create NSVCt\n"); gprs_ns_destroy(bssgp_nsi); bssgp_nsi = NULL; @@ -620,7 +628,7 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, bctx = btsctx_alloc(bvci, nsei); if (!bctx) { LOGP(DBSSGP, LOGL_ERROR, "Failed to create BSSGP context\n"); - nsvc = NULL; + the_pcu.nsvc = NULL; gprs_ns_destroy(bssgp_nsi); bssgp_nsi = NULL; return -EINVAL; @@ -643,7 +651,7 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, void gprs_bssgp_destroy_or_exit(void) { - if (exit_on_destroy) { + if (the_pcu.exit_on_destroy) { LOGP(DBSSGP, LOGL_NOTICE, "Exiting on BSSGP destruction.\n"); exit(0); } @@ -655,7 +663,7 @@ void gprs_bssgp_destroy_or_exit(void) osmo_signal_unregister_handler(SS_L_NS, nsvc_signal_cb, NULL); - nsvc = NULL; + the_pcu.nsvc = NULL; /* FIXME: move this to libgb: btsctx_free() */ llist_del(&bctx->list); @@ -671,5 +679,5 @@ void gprs_bssgp_destroy_or_exit(void) void gprs_bssgp_exit_on_destroy(void) { LOGP(DBSSGP, LOGL_NOTICE, "Going to quit on BSSGP destruction\n"); - exit_on_destroy = 1; + the_pcu.exit_on_destroy = 1; } -- 1.8.3.2 From hfreyther at sysmocom.de Sat Jul 27 20:20:53 2013 From: hfreyther at sysmocom.de (Holger Freyther) Date: Sat, 27 Jul 2013 22:20:53 +0200 Subject: [PATCH 7/8] bssgp: Remove commented out code that is currently not used. In-Reply-To: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1374956454-26827-7-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther --- src/gprs_bssgp_pcu.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index 2e93a02..b90f2c5 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -545,8 +545,6 @@ int gprs_bssgp_tx_fc_bvc(void) /* FIXME: use real values */ return bssgp_tx_fc_bvc(the_pcu.bctx, 1, 6553500, 819100, 50000, 50000, NULL, NULL); -// return bssgp_tx_fc_bvc(bctx, 1, 84000, 25000, 48000, 45000, -// NULL, NULL); } static void bvc_timeout(void *_priv) @@ -641,8 +639,6 @@ int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, osmo_signal_register_handler(SS_L_NS, nsvc_signal_cb, NULL); -// bssgp_tx_bvc_reset(the_pcu.bctx, the_pcu.bctx->bvci, BSSGP_CAUSE_PROTO_ERR_UNSPEC); - the_pcu.bvc_timer.cb = bvc_timeout; -- 1.8.3.2 From laforge at gnumonks.org Mon Jul 29 10:51:13 2013 From: laforge at gnumonks.org (Harald Welte) Date: Mon, 29 Jul 2013 18:51:13 +0800 Subject: [PATCH 2/2] misc: Add an option exit/quit when the BSSGP is supposed to be destroyed In-Reply-To: References: <1373722452-2868-1-git-send-email-holger@moiji-mobile.com> <1373722452-2868-2-git-send-email-holger@moiji-mobile.com> Message-ID: <20130729105113.GC8492@nataraja.gnumonks.org> Hi Ivan, On Thu, Jul 25, 2013 at 08:27:04PM +0400, Ivan Kluchnikov wrote: > Actually I think that we should implement more intellectual behavior > of PCUfor handling restarts and disconnections of BTS and SGSN. I think there is nothing wrong with a 'fail fast' approach. the SGSN disconnecting should be a rare event. The PCU is a small process. Exiting and re-spawning just to make 100% sure that no bogus state remains is a valid approach from my point of view. osmo-bts also does it the same way. It's not like we're talking about a 200MByte sized complex process where re-spawning is an expensive operation. 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 hfreyther at sysmocom.de Mon Jul 29 11:25:54 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Mon, 29 Jul 2013 13:25:54 +0200 Subject: [PATCH 1/8] misc: Introduce a struct osmo_pcu and move things into it. In-Reply-To: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <20130729112554.GD18752@xiaoyu.lan> On Sat, Jul 27, 2013 at 10:20:47PM +0200, Holger Freyther wrote: Dear Ivan, I have 14 more patches after this patchset. Could you please indicate how we can end up with a mode where my commit queue is draining within a reasonable amount of time? I started with the PCU Emu to re-produce some SGSN issue(s). I really appreciate someone reviewing and arguing about the changes I do and each individual one is fairly small and one topic at a time. Any ideas? kind regards holger -- - Holger Freyther http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Schivelbeiner Str. 5 * 10439 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From hfreyther at sysmocom.de Mon Jul 29 11:33:31 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Mon, 29 Jul 2013 13:33:31 +0200 Subject: C++ for the PCU Message-ID: <20130729113331.GE18752@xiaoyu.lan> Dear Ivan, all, I started to do work on the PCU and didn't compile C++ for a long time. I was surprised how long it takes to compile the code. From my point of view we are taking the hit of g++ without really using any of the features that C++ vould provide (e.g. no stack variables with automatic cleanup..). From andreas at eversberg.eu Mon Jul 29 15:20:58 2013 From: andreas at eversberg.eu (Andreas Eversberg) Date: Mon, 29 Jul 2013 17:20:58 +0200 Subject: C++ for the PCU In-Reply-To: <20130729113331.GE18752@xiaoyu.lan> References: <20130729113331.GE18752@xiaoyu.lan> Message-ID: <51F6885A.1080208@eversberg.eu> Holger Hans Peter Freyther wrote: > From my point > of view we are taking the hit of g++ without really using any of the > features that C++ vould provide (e.g. no stack variables with automatic > cleanup..). > hi holger, i have some old patches somewhere that turn everything from c++ to c, except the dissecting part, which stays c++, iirc. i never finished them, because there was someone doing a similar work, so i didn't want to do double work. in my opinion it makes sense to change it, since we don't (and won't) use any c++ features at our code. > I think we should find a more nice solution to extern "C". that would be my solution. if you like, i could dig these patches out. regards, andreas From Ivan.Kluchnikov at fairwaves.ru Tue Jul 30 07:42:29 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Tue, 30 Jul 2013 11:42:29 +0400 Subject: C++ for the PCU In-Reply-To: <51F6885A.1080208@eversberg.eu> References: <20130729113331.GE18752@xiaoyu.lan> <51F6885A.1080208@eversberg.eu> Message-ID: Hi Holger and Andreas, I agree with Andreas, actually most of the code is c, not c++, so I think that the right solution is to get rid of ?++ completely. Andreas, if you have patches for that and time, I believe that it make sense to create new branch with these patches. After that I can try to turn dissecting part from c++ to c. What do you think about it? 2013/7/29 Andreas Eversberg > Holger Hans Peter Freyther wrote: > > From my point > > of view we are taking the hit of g++ without really using any of the > > features that C++ vould provide (e.g. no stack variables with automatic > > cleanup..). > > > hi holger, > > i have some old patches somewhere that turn everything from c++ to c, > except the dissecting part, which stays c++, iirc. i never finished > them, because there was someone doing a similar work, so i didn't want > to do double work. in my opinion it makes sense to change it, since we > don't (and won't) use any c++ features at our code. > > > I think we should find a more nice solution to extern "C". > that would be my solution. if you like, i could dig these patches out. > > regards, > > andreas > > > > > -- Regards, Ivan Kluchnikov. http://fairwaves.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.chemeris at gmail.com Tue Jul 30 07:50:23 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Tue, 30 Jul 2013 11:50:23 +0400 Subject: C++ for the PCU In-Reply-To: <20130729113331.GE18752@xiaoyu.lan> References: <20130729113331.GE18752@xiaoyu.lan> Message-ID: Hi Holger, Do you have a clear idea what could be done easier/better/safer with C++ in this case? I general I'm a big fan of C++ because it's easier to write safe/better code, but in this exact case we're already deep into C style and I'm not sure we could change that with a reasonable amount of effort. If you have concrete proposals, please send them for discussion. Otherwise I agree that we should change the code to be pure C, even though I don't like C. On Mon, Jul 29, 2013 at 3:33 PM, Holger Hans Peter Freyther wrote: > Dear Ivan, all, > > I started to do work on the PCU and didn't compile C++ for a long time. > I was surprised how long it takes to compile the code. From my point > of view we are taking the hit of g++ without really using any of the > features that C++ vould provide (e.g. no stack variables with automatic > cleanup..). > > From here I wonder if we should use gcc for more speedy compiles or > if we should use more C++ features (I am not talking STL, operator > overloading)? > > Any opinions? > > holger > > PS: I think we should find a more nice solution to extern "C".. I > spent various minutes trying to figure out which parts of the pcu > have C linkage and which C++.. For things from libosmocore it is > obvious.. but then we have the vty_info... > > -- > - Holger Freyther http://www.sysmocom.de/ > ======================================================================= > * sysmocom - systems for mobile communications GmbH > * Schivelbeiner Str. 5 > * 10439 Berlin, Germany > * Sitz / Registered office: Berlin, HRB 134158 B > * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte > > -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From hfreyther at sysmocom.de Tue Jul 30 08:20:48 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 10:20:48 +0200 Subject: C++ for the PCU In-Reply-To: References: <20130729113331.GE18752@xiaoyu.lan> Message-ID: <20130730082048.GG14730@xiaoyu.lan> On Tue, Jul 30, 2013 at 11:50:23AM +0400, Alexander Chemeris wrote: > Hi Holger, > > Do you have a clear idea what could be done easier/better/safer with > C++ in this case? I general I'm a big fan of C++ because it's easier > to write safe/better code, but in this exact case we're already deep > into C style and I'm not sure we could change that with a reasonable > amount of effort. If you have concrete proposals, please send them for > discussion. Otherwise I agree that we should change the code to be > pure C, even though I don't like C. I would convert the C modules to C. In terms of C++ I still wonder how it could help. E.g. bitvec could be a C++ class. Then we would have the 23bytes on the stack (maybe one template instantiation for the case of 23 bytes)... but given the state of things C might just be the easiest route. -- - Holger Freyther http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Schivelbeiner Str. 5 * 10439 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From Ivan.Kluchnikov at fairwaves.ru Tue Jul 30 08:56:59 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Tue, 30 Jul 2013 12:56:59 +0400 Subject: [PATCH 1/8] misc: Introduce a struct osmo_pcu and move things into it. In-Reply-To: <20130729112554.GD18752@xiaoyu.lan> References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> <20130729112554.GD18752@xiaoyu.lan> Message-ID: Hi Holger, I looked through your patches and commited them to master, all of them are reasonable. I have only one question about the name of the this variable: +static struct osmo_pcu the_pcu = { 0, }; Why do you use "the_pcu", not "pcu"? Actually it is not the problem, just unusual for me. :) Now I am ready for new patchset. What is the reasonable amount of time for patchset review for you? Sometimes I am overloaded by other work, but I will try to delay review no longer than 1-2 days. Another mode, you can commit patches to master by yourself and just notify about it mailing list. 2013/7/29 Holger Hans Peter Freyther > On Sat, Jul 27, 2013 at 10:20:47PM +0200, Holger Freyther wrote: > > Dear Ivan, > > I have 14 more patches after this patchset. Could you please indicate > how we can end up with a mode where my commit queue is draining within > a reasonable amount of time? I started with the PCU Emu to re-produce > some SGSN issue(s). > > I really appreciate someone reviewing and arguing about the changes > I do and each individual one is fairly small and one topic at a time. > > Any ideas? > > kind regards > holger > > > > -- > - Holger Freyther http://www.sysmocom.de/ > ======================================================================= > * sysmocom - systems for mobile communications GmbH > * Schivelbeiner Str. 5 > * 10439 Berlin, Germany > * Sitz / Registered office: Berlin, HRB 134158 B > * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte > > > -- Regards, Ivan Kluchnikov. http://fairwaves.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: From hfreyther at sysmocom.de Tue Jul 30 09:01:43 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 11:01:43 +0200 Subject: [PATCH 1/8] misc: Introduce a struct osmo_pcu and move things into it. In-Reply-To: References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> <20130729112554.GD18752@xiaoyu.lan> Message-ID: <20130730090143.GH14730@xiaoyu.lan> On Tue, Jul 30, 2013 at 12:56:59PM +0400, Ivan Kluchnikov wrote: > Hi Holger, Dear Ivan, thanks a lot. > +static struct osmo_pcu the_pcu = { 0, }; > Why do you use "the_pcu", not "pcu"? I wanted to differentiate that 'pcu' is not a local variable. I could have picked g_pcu or something else. I used 'the' because there is only one pcu right now. I will remove that limit though (and remove global state from the PCU). > Now I am ready for new patchset. Thanks. I will send things tomorrow. > What is the reasonable amount of time for patchset review for you? > Sometimes I am overloaded by other work, but I will try to delay review no > longer than 1-2 days. 'reasonable' anything < 5 days. I just want to avoid ending with 40 patches and you as the maintainer not having time to look at them. E.g. for OpenBSC I try to at least give a quick NACK/or ask for changes. > Another mode, you can commit patches to master by yourself and just notify > about it mailing list. I would love to have more eyes before the commit hits the repository. Everybody is making mistakes and it would be nice if mine are catched with review too. cheers holger -- - Holger Freyther http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Schivelbeiner Str. 5 * 10439 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From Ivan.Kluchnikov at fairwaves.ru Tue Jul 30 09:17:36 2013 From: Ivan.Kluchnikov at fairwaves.ru (Ivan Kluchnikov) Date: Tue, 30 Jul 2013 13:17:36 +0400 Subject: [PATCH 1/8] misc: Introduce a struct osmo_pcu and move things into it. In-Reply-To: <20130730090143.GH14730@xiaoyu.lan> References: <1374956454-26827-1-git-send-email-hfreyther@sysmocom.de> <20130729112554.GD18752@xiaoyu.lan> <20130730090143.GH14730@xiaoyu.lan> Message-ID: 2013/7/30 Holger Hans Peter Freyther > I wanted to differentiate that 'pcu' is not a local variable. I could > have picked g_pcu or something else. I used 'the' because there is only > one pcu right now. I will remove that limit though (and remove global > state from the PCU). > Ok, I understand. > > > Now I am ready for new patchset. > > Thanks. I will send things tomorrow. > > > > What is the reasonable amount of time for patchset review for you? > > Sometimes I am overloaded by other work, but I will try to delay review > no > > longer than 1-2 days. > > 'reasonable' anything < 5 days. I just want to avoid ending with 40 > patches and you as the maintainer not having time to look at them. E.g. > for OpenBSC I try to at least give a quick NACK/or ask for changes. > I think we should use this mode, because as you mentioned, reviews are the good opportunity to catch mistakes. -- Regards, Ivan Kluchnikov. http://fairwaves.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: From hfreyther at sysmocom.de Tue Jul 30 19:26:39 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 21:26:39 +0200 Subject: [PATCH 1/9] misc: Ignore the two osmo-pcu binaries and files created by vim Message-ID: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 032b9cf..4f418d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.o *.lo *.a +*.sw? Makefile.in Makefile .deps @@ -22,3 +23,7 @@ core core.* osmoappdesc.pyc + +# binaries +src/osmo-pcu +src/osmo-pcu-remote -- 1.8.3.2 From hfreyther at sysmocom.de Tue Jul 30 19:26:41 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 21:26:41 +0200 Subject: [PATCH 3/9] csn1: Fix various printf/format issues pointed out by gcc In-Reply-To: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1375212407-2209-3-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther This might clash with C++11 and literal values but we will see that once the compilers enable that by default. Fixes: csn1.cpp: In function 'gint16 csnStreamDecoder(csnStream_t*, const CSN_DESCR*, bitvec*, unsigned int&, void*)': csn1.cpp:864:17: warning: format '%d' expects argument of type 'int', but argument 8 has type 'guint64 {aka long unsigned int}' [-Wformat] csn1.cpp:1144:15: warning: format '%u' expects argument of type 'unsigned int', but argument 7 has type 'uint64_t {aka long long unsigned int}' [-Wformat] csn1.cpp:1150:15: warning: format '%u' expects argument of type 'unsigned int', but argument 7 has type 'uint64_t {aka long long unsigned int}' [-Wformat] csn1.cpp: In function 'gint16 csnStreamEncoder(csnStream_t*, const CSN_DESCR*, bitvec*, unsigned int&, void*)': csn1.cpp:2119:17: warning: format '%d' expects argument of type 'int', but argument 8 has type 'guint64 {aka long unsigned int}' [-Wformat] --- src/csn1.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/csn1.cpp b/src/csn1.cpp index de1db73..45cc848 100644 --- a/src/csn1.cpp +++ b/src/csn1.cpp @@ -32,6 +32,8 @@ #include #include #include +#define __STDC_FORMAT_MACROS +#include #include "csn1.h" #include @@ -861,7 +863,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig guint64 ui64 = bitvec_read_field(vector, readIndex, no_of_bits); pui64 = pui64DATA(data, pDescr->offset); *pui64 = ui64; - LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui64); + LOGPC(DCSN1, LOGL_NOTICE, "%s = %lu | ", pDescr->sz , *pui64); } else { @@ -1141,13 +1143,13 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig guint8 bits_to_handle = remaining_bits_len%8; if (bits_to_handle > 0) { - LOGPC(DCSN1, LOGL_NOTICE, "%u|", bitvec_read_field(vector, readIndex, bits_to_handle)); + LOGPC(DCSN1, LOGL_NOTICE, "%"PRIu64"|", bitvec_read_field(vector, readIndex, bits_to_handle)); remaining_bits_len -= bits_to_handle; bit_offset += bits_to_handle; } else if (bits_to_handle == 0) { - LOGPC(DCSN1, LOGL_NOTICE, "%u|", bitvec_read_field(vector, readIndex, 8)); + LOGPC(DCSN1, LOGL_NOTICE, "%"PRIu64"|", bitvec_read_field(vector, readIndex, 8)); remaining_bits_len -= 8; bit_offset += 8; } @@ -2116,7 +2118,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector { pui64 = pui64DATA(data, pDescr->offset); bitvec_write_field(vector, writeIndex, *pui64, no_of_bits); - LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui64); + LOGPC(DCSN1, LOGL_NOTICE, "%s = %lu | ", pDescr->sz , *pui64); } else { -- 1.8.3.2 From hfreyther at sysmocom.de Tue Jul 30 19:26:40 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 21:26:40 +0200 Subject: [PATCH 2/9] csn1: Remove unused code from the file In-Reply-To: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1375212407-2209-2-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther Fixes: csn1.cpp:124:20: warning: 'CSN_DESCR_type' defined but not used [-Wunused-variable] --- src/csn1.cpp | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/csn1.cpp b/src/csn1.cpp index 38d8860..de1db73 100644 --- a/src/csn1.cpp +++ b/src/csn1.cpp @@ -118,44 +118,6 @@ ProcessError( unsigned readIndex, const char* sz, gint16 err, const CSN_DESCR* p return err; } -//#if 0 -static const char* CSN_DESCR_type[]= -{ - "CSN_END", - "CSN_BIT", - "CSN_UINT", - "CSN_TYPE", - "CSN_CHOICE", - "CSN_UNION", - "CSN_UNION_LH", - "CSN_UINT_ARRAY", - "CSN_TYPE_ARRAY", - "CSN_BITMAP", - "CSN_VARIABLE_BITMAP", - "CSN_VARIABLE_BITMAP_1", - "CSN_LEFT_ALIGNED_VAR_BMP", - "CSN_LEFT_ALIGNED_VAR_BMP_1", - "CSN_VARIABLE_ARRAY", - "CSN_VARIABLE_TARRAY", - "CSN_VARIABLE_TARRAY_OFFSET", - "CSN_RECURSIVE_ARRAY", - "CSN_RECURSIVE_TARRAY", - "CSN_RECURSIVE_TARRAY_1", - "CSN_RECURSIVE_TARRAY_2", - "CSN_EXIST", - "CSN_EXIST_LH", - "CSN_NEXT_EXIST", - "CSN_NEXT_EXIST_LH", - "CSN_NULL", - "CSN_FIXED", - "CSN_CALLBACK", - "CSN_UINT_OFFSET", - "CSN_UINT_LH", - "CSN_SERIALIZE", - "CSN_TRAP_ERROR" - "CSN_???" -}; -//#endif /** * ================================================================================================ -- 1.8.3.2 From hfreyther at sysmocom.de Tue Jul 30 19:26:42 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 21:26:42 +0200 Subject: [PATCH 4/9] femtobts: Remove code that is causing warnings with GCC 4.8 In-Reply-To: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1375212407-2209-4-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther femtobts.c:250:2: warning: excess elements in array initializer [enabled by default] { SuperFemto_ClkSrcId_NetList, "nwl" }, ^ femtobts.c:250:2: warning: (near initialization for ?femtobts_clksrc_names?) [enabled by default] femtobts.c:251:2: warning: excess elements in array initializer [enabled by default] { 0, NULL } ^ femtobts.c:251:2: warning: (near initialization for ?femtobts_clksrc_names?) [enabled by default] --- src/femtobts.c | 13 ------------- src/femtobts.h | 2 -- 2 files changed, 15 deletions(-) diff --git a/src/femtobts.c b/src/femtobts.c index 69b33be..f6957d2 100644 --- a/src/femtobts.c +++ b/src/femtobts.c @@ -238,19 +238,6 @@ const struct value_string femtobts_tch_pl_names[] = { { 0, NULL } }; -const struct value_string femtobts_clksrc_names[] = { - { SuperFemto_ClkSrcId_None, "None" }, - { SuperFemto_ClkSrcId_Ocxo, "ocxo" }, - { SuperFemto_ClkSrcId_Tcxo, "tcxo" }, - { SuperFemto_ClkSrcId_External, "ext" }, - { SuperFemto_ClkSrcId_GpsPps, "gps" }, - { SuperFemto_ClkSrcId_Trx, "trx" }, - { SuperFemto_ClkSrcId_Rx, "rx" }, - { SuperFemto_ClkSrcId_Edge, "edge" }, - { SuperFemto_ClkSrcId_NetList, "nwl" }, - { 0, NULL } -}; - const struct value_string femtobts_dir_names[] = { { GsmL1_Dir_TxDownlink, "TxDL" }, { GsmL1_Dir_TxUplink, "TxUL" }, diff --git a/src/femtobts.h b/src/femtobts.h index f2ac59d..7e45578 100644 --- a/src/femtobts.h +++ b/src/femtobts.h @@ -33,8 +33,6 @@ const struct value_string femtobts_tracef_names[29]; const struct value_string femtobts_tch_pl_names[15]; -const struct value_string femtobts_clksrc_names[8]; - const struct value_string femtobts_dir_names[6]; enum pdch_cs { -- 1.8.3.2 From hfreyther at sysmocom.de Tue Jul 30 19:26:45 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 21:26:45 +0200 Subject: [PATCH 7/9] bssgp: The method creates and the connects.. reflect that in the name In-Reply-To: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1375212407-2209-7-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther Call things by what they do. This method is creating and then connecting a BSSGP.. --- src/gprs_bssgp_pcu.cpp | 2 +- src/gprs_bssgp_pcu.h | 2 +- src/pcu_l1_if.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index e994f9f..ae47fb2 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -592,7 +592,7 @@ static void bvc_timeout(void *_priv) } /* create BSSGP/NS layer instances */ -int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, +int gprs_bssgp_create_and_connect(uint16_t local_port, uint32_t sgsn_ip, uint16_t sgsn_port, uint16_t nsei, uint16_t nsvci, uint16_t bvci, uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac, uint16_t cell_id) diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h index dff86a3..b611a19 100644 --- a/src/gprs_bssgp_pcu.h +++ b/src/gprs_bssgp_pcu.h @@ -49,7 +49,7 @@ int gprs_bssgp_pcu_rx_sign(struct msgb *msg, struct tlv_parsed *tp, struct bssgp int gprs_bssgp_pcu_rcvmsg(struct msgb *msg); -int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, uint16_t +int gprs_bssgp_create_and_connect(uint16_t local_port, uint32_t sgsn_ip, uint16_t sgsn_port, uint16_t nsei, uint16_t nsvci, uint16_t bvci, uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac, uint16_t cell_id); diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 4452f0f..b7b0269 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -418,7 +418,7 @@ bssgp_failed: ia.s_addr = htonl(info_ind->remote_ip[0]); LOGP(DL1IF, LOGL_DEBUG, " remote_ip=%s\n", inet_ntoa(ia)); - rc = gprs_bssgp_create(info_ind->local_port[0], + rc = gprs_bssgp_create_and_connect(info_ind->local_port[0], info_ind->remote_ip[0], info_ind->remote_port[0], info_ind->nsei, info_ind->nsvci[0], info_ind->bvci, info_ind->mcc, info_ind->mnc, info_ind->lac, info_ind->rac, -- 1.8.3.2 From hfreyther at sysmocom.de Tue Jul 30 19:26:46 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 21:26:46 +0200 Subject: [PATCH 8/9] tests: Create tests directory and move the VTY testing into there In-Reply-To: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1375212407-2209-8-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther --- Makefile.am | 13 +------------ configure.ac | 1 + tests/Makefile.am | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 tests/Makefile.am diff --git a/Makefile.am b/Makefile.am index e23a40f..4cbc114 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,16 +1,5 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 -SUBDIRS = src examples +SUBDIRS = src examples tests EXTRA_DIST = osmoappdesc.py -if ENABLE_VTY_TESTS -python-tests: $(BUILT_SOURCES) - osmotestvty.py -p $(top_srcdir) -w $(builddir) -v - osmotestconfig.py -p $(top_srcdir) -w $(builddir) -v -else -python-tests: $(BUILT_SOURCES) - @echo "Not running python-based tests (determined at configure-time)" -endif - -check-local: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) python-tests diff --git a/configure.ac b/configure.ac index 6510bf4..58cbc35 100644 --- a/configure.ac +++ b/configure.ac @@ -60,4 +60,5 @@ AM_CONDITIONAL(ENABLE_VTY_TESTS, test "x$enable_vty_tests" = "xyes") AC_OUTPUT( src/Makefile examples/Makefile + tests/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..7581ea9 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,16 @@ + + + +# Python testing +if ENABLE_VTY_TESTS +python-tests: $(BUILT_SOURCES) + osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v + osmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v + +else +python-tests: $(BUILT_SOURCES) + @echo "Not running python-based tests (determined at configure-time)" +endif + +check-local: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) python-tests -- 1.8.3.2 From hfreyther at sysmocom.de Tue Jul 30 19:26:47 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 21:26:47 +0200 Subject: [PATCH 9/9] tests: Move the RLCMACTest into the test directory and setup autotest In-Reply-To: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1375212407-2209-9-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther --- .gitignore | 8 ++ configure.ac | 1 + src/Makefile.am | 11 +-- src/RLCMACTest.cpp | 218 -------------------------------------------- tests/Makefile.am | 50 +++++++++- tests/rlcmac/RLCMACTest.cpp | 218 ++++++++++++++++++++++++++++++++++++++++++++ tests/rlcmac/RLCMACTest.err | 0 tests/rlcmac/RLCMACTest.ok | 58 ++++++++++++ tests/testsuite.at | 10 ++ 9 files changed, 346 insertions(+), 228 deletions(-) delete mode 100644 src/RLCMACTest.cpp create mode 100644 tests/rlcmac/RLCMACTest.cpp create mode 100644 tests/rlcmac/RLCMACTest.err create mode 100644 tests/rlcmac/RLCMACTest.ok create mode 100644 tests/testsuite.at diff --git a/.gitignore b/.gitignore index 4f418d8..fec1b98 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,11 @@ osmoappdesc.pyc # binaries src/osmo-pcu src/osmo-pcu-remote + +# tests +tests/atconfig +tests/package.m4 +tests/rlcmac/.dirstamp +tests/rlcmac/RLCMACTest +tests/testsuite +tests/testsuite.log diff --git a/configure.ac b/configure.ac index 58cbc35..3b2f380 100644 --- a/configure.ac +++ b/configure.ac @@ -4,6 +4,7 @@ AC_INIT([osmo-pcu], [osmocom-pcu at lists.osmocom.org]) AM_INIT_AUTOMAKE([dist-bzip2]) +AC_CONFIG_TESTDIR(tests) dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff --git a/src/Makefile.am b/src/Makefile.am index b20b0a9..38a4b3c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,12 +50,11 @@ libgprs_la_SOURCES += \ openbts_sock.cpp endif -noinst_PROGRAMS = \ - RLCMACTest - bin_PROGRAMS = \ osmo-pcu +noinst_PROGRAMS = + if ENABLE_SYSMODSP noinst_PROGRAMS += \ osmo-pcu-remote @@ -75,12 +74,6 @@ noinst_HEADERS = \ sysmo_l1_if.h \ femtobts.h -RLCMACTest_SOURCES = RLCMACTest.cpp -RLCMACTest_LDADD = \ - libgprs.la \ - $(LIBOSMOCORE_LIBS) \ - $(COMMON_LA) - osmo_pcu_SOURCES = pcu_main.cpp if ENABLE_SYSMODSP diff --git a/src/RLCMACTest.cpp b/src/RLCMACTest.cpp deleted file mode 100644 index 843dc21..0000000 --- a/src/RLCMACTest.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* RLCMACTest.cpp - * - * Copyright (C) 2011 Ivan Klyuchnikov - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - - - -//#include -#include -#include -#include -#include "csn1.h" -#include "gsm_rlcmac.h" -extern "C" { -extern const struct log_info gprs_log_info; -#include "pcu_vty.h" -#include -#include -#include -} -using namespace std; - -void printSizeofRLCMAC() -{ - cout << "sizeof RlcMacUplink_t " << sizeof(RlcMacUplink_t) << endl; - cout << "sizeof Packet_Cell_Change_Failure_t " << sizeof(Packet_Cell_Change_Failure_t) << endl; - cout << "sizeof Packet_Control_Acknowledgement_t " << sizeof(Packet_Control_Acknowledgement_t) << endl; - cout << "sizeof Packet_Downlink_Ack_Nack_t " << sizeof(Packet_Downlink_Ack_Nack_t) << endl; - cout << "sizeof EGPRS_PD_AckNack_t " << sizeof(EGPRS_PD_AckNack_t) << endl; - cout << "sizeof Packet_Uplink_Dummy_Control_Block_t " << sizeof(Packet_Uplink_Dummy_Control_Block_t) << endl; - cout << "sizeof Packet_Measurement_Report_t " << sizeof(Packet_Measurement_Report_t) << endl; - cout << "sizeof Packet_Resource_Request_t " << sizeof(Packet_Resource_Request_t) << endl; - cout << "sizeof Packet_Mobile_TBF_Status_t " << sizeof(Packet_Mobile_TBF_Status_t) << endl; - cout << "sizeof Packet_PSI_Status_t " << sizeof(Packet_PSI_Status_t) << endl; - cout << "sizeof Packet_Enh_Measurement_Report_t " << sizeof(Packet_Enh_Measurement_Report_t) << endl; - cout << "sizeof Packet_Cell_Change_Notification_t " << sizeof(Packet_Cell_Change_Notification_t) << endl; - cout << "sizeof Packet_SI_Status_t " << sizeof(Packet_SI_Status_t) << endl; - cout << "sizeof Additional_MS_Rad_Access_Cap_t " << sizeof(Additional_MS_Rad_Access_Cap_t) << endl; - cout << "sizeof Packet_Pause_t " << sizeof(Packet_Pause_t) << endl; - - cout << "sizeof RlcMacDownlink_t " << sizeof(RlcMacDownlink_t) << endl; - cout << "sizeof Packet_Access_Reject_t " << sizeof(Packet_Access_Reject_t) << endl; - cout << "sizeof Packet_Cell_Change_Order_t " << sizeof(Packet_Cell_Change_Order_t) << endl; - cout << "sizeof Packet_Downlink_Assignment_t " << sizeof(Packet_Downlink_Assignment_t) << endl; - cout << "sizeof Packet_Measurement_Order_Reduced_t " << sizeof(Packet_Measurement_Order_Reduced_t) << endl; - cout << "sizeof Packet_Neighbour_Cell_Data_t " << sizeof(Packet_Neighbour_Cell_Data_t) << endl; - cout << "sizeof Packet_Serving_Cell_Data_t " << sizeof(Packet_Serving_Cell_Data_t) << endl; - cout << "sizeof Packet_Paging_Request_t " << sizeof(Packet_Paging_Request_t) << endl; - cout << "sizeof Packet_PDCH_Release_t " << sizeof(Packet_PDCH_Release_t) << endl; - cout << "sizeof Packet_Polling_Request_t " << sizeof(Packet_Polling_Request_t) << endl; - cout << "sizeof Packet_Power_Control_Timing_Advance_t " << sizeof(Packet_Power_Control_Timing_Advance_t) << endl; - cout << "sizeof Packet_PRACH_Parameters_t " << sizeof(Packet_PRACH_Parameters_t) << endl; - cout << "sizeof Packet_Queueing_Notification_t " << sizeof(Packet_Queueing_Notification_t) << endl; - cout << "sizeof Packet_Timeslot_Reconfigure_t " << sizeof(Packet_Timeslot_Reconfigure_t) << endl; - cout << "sizeof Packet_TBF_Release_t " << sizeof(Packet_TBF_Release_t) << endl; - cout << "sizeof Packet_Uplink_Ack_Nack_t " << sizeof(Packet_Uplink_Ack_Nack_t) << endl; - cout << "sizeof Packet_Uplink_Assignment_t " << sizeof(Packet_Uplink_Assignment_t) << endl; - cout << "sizeof Packet_Cell_Change_Continue_t " << sizeof(Packet_Cell_Change_Continue_t) << endl; - cout << "sizeof Packet_Handover_Command_t " << sizeof(Packet_Handover_Command_t) << endl; - cout << "sizeof Packet_PhysicalInformation_t " << sizeof(Packet_PhysicalInformation_t) << endl; - cout << "sizeof Packet_Downlink_Dummy_Control_Block_t " << sizeof(Packet_Downlink_Dummy_Control_Block_t) << endl; - cout << "sizeof PSI1_t " << sizeof(PSI1_t) << endl; - cout << "sizeof PSI2_t " << sizeof(PSI2_t) << endl; - cout << "sizeof PSI3_t " << sizeof(PSI3_t) << endl; - cout << "sizeof PSI3_BIS_t " << sizeof(PSI3_BIS_t) << endl; - cout << "sizeof PSI4_t " << sizeof(PSI4_t) << endl; - cout << "sizeof PSI13_t " << sizeof(PSI13_t) << endl; - cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl; -} - -void testRlcMacDownlink() -{ - struct bitvec *resultVector = bitvec_alloc(23); - bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); - - std::string testData[] = { - "4e082500e3f1a81d080820800b2b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment - "48282407a6a074227201000b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment - "47240c00400000000000000079eb2ac9402b2b2b2b2b2b", // Packet Uplink Ack Nack - "47283c367513ba333004242b2b2b2b2b2b2b2b2b2b2b2b" // Packet Uplink Assignment - "4913e00850884013a8048b2b2b2b2b2b2b2b2b2b2b2b2b" - "412430007fffffffffffffffefd19c7ba12b2b2b2b2b2b" - "41942b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b" - }; - - int testDataSize = sizeof(testData)/sizeof(testData[0]); - - cout << " DOWNLINK " << endl; - for (int i = 0; i < testDataSize; i++) - { - bitvec *vector = bitvec_alloc(23); - bitvec_unhex(vector, testData[i].c_str()); - cout << "vector1 = "; - for (int i = 0; i < 23; i++) - { - cout << hex << (unsigned)*(vector->data + i); - } - cout << endl; - RlcMacDownlink_t * data = (RlcMacDownlink_t *)malloc(sizeof(RlcMacDownlink_t)); - cout << "=========Start DECODE===========" << endl; - decode_gsm_rlcmac_downlink(vector, data); - cout << "+++++++++Finish DECODE++++++++++" << endl; - cout << "=========Start ENCODE=============" << endl; - encode_gsm_rlcmac_downlink(resultVector, data); - cout << "+++++++++Finish ENCODE+++++++++++" << endl; - cout << "vector1 = "; - for (int i = 0; i < 23; i++) - { - cout << (unsigned)*(vector->data + i); - } - cout << endl; - cout << "vector2 = "; - for (int i = 0; i < 23; i++) - { - cout << (unsigned)*(resultVector->data + i); - } - cout << endl; - if (memcmp(vector->data, resultVector->data, 23) == 0) - { - cout << "vector1 == vector2 : TRUE" << endl; - } - else - { - cout << "vector1 == vector2 : FALSE" << endl; - } - bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); - bitvec_free(vector); - free(data); - } - - bitvec_free(resultVector); -} - - -void testRlcMacUplink() -{ - struct bitvec *resultVector = bitvec_alloc(23); - bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); - - std::string testData[] = { - "400e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Dummy Control Block - "400b8020000000000000002480e00b2b2b2b2b2b2b2b2b", // Packet Downlink Ack/Nack - "4016713dc094270ca2ae57ef909006aa0fc0001f80222b" // Packet Resource Request - "400a9020000000000000003010012a0800132b2b2b2b2b" - }; - - int testDataSize = sizeof(testData)/sizeof(testData[0]); - - - cout << " UPLINK " << endl; - for (int i = 0; i < testDataSize; i++) - { - bitvec *vector = bitvec_alloc(23); - bitvec_unhex(vector, testData[i].c_str()); - cout << "vector1 = "; - for (int i = 0; i < 23; i++) - { - cout << hex << (unsigned)*(vector->data + i); - } - cout << endl; - RlcMacUplink_t * data = (RlcMacUplink_t *)malloc(sizeof(RlcMacUplink_t)); - cout << "=========Start DECODE===========" << endl; - decode_gsm_rlcmac_uplink(vector, data); - cout << "+++++++++Finish DECODE++++++++++" << endl; - cout << "=========Start ENCODE=============" << endl; - encode_gsm_rlcmac_uplink(resultVector, data); - cout << "+++++++++Finish ENCODE+++++++++++" << endl; - cout << "vector1 = "; - for (int i = 0; i < 23; i++) - { - cout << (unsigned)*(vector->data + i); - } - cout << endl; - cout << "vector2 = "; - for (int i = 0; i < 23; i++) - { - cout << (unsigned)*(resultVector->data + i); - } - cout << endl; - if (memcmp(vector->data, resultVector->data, 23) == 0) - { - cout << "vector1 == vector2 : TRUE" << endl; - } - else - { - cout << "vector1 == vector2 : FALSE" << endl; - } - bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); - bitvec_free(vector); - free(data); - } - - bitvec_free(resultVector); -} - -int main(int argc, char *argv[]) -{ - osmo_init_logging(&gprs_log_info); - - //printSizeofRLCMAC(); - testRlcMacDownlink(); - testRlcMacUplink(); - -} diff --git a/tests/Makefile.am b/tests/Makefile.am index 7581ea9..1faa5f4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,38 @@ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGB_CFLAGS) $(LIBOSMOGSM_CFLAGS) -I$(top_srcdir)/src/ +check_PROGRAMS = rlcmac/RLCMACTest +rlcmac_RLCMACTest_SOURCES = rlcmac/RLCMACTest.cpp +rlcmac_RLCMACTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ + $(LIBOSMOCORE_LIBS) \ + $(COMMON_LA) + +# The `:;' works around a Bash 3.2 bug when the output is not writeable. +$(srcdir)/package.m4: $(top_srcdir)/configure.ac + :;{ \ + echo '# Signature of the current package.' && \ + echo 'm4_define([AT_PACKAGE_NAME],' && \ + echo ' [$(PACKAGE_NAME)])' && \ + echo 'm4_define([AT_PACKAGE_TARNAME],' && \ + echo ' [$(PACKAGE_TARNAME)])' && \ + echo 'm4_define([AT_PACKAGE_VERSION],' && \ + echo ' [$(PACKAGE_VERSION)])' && \ + echo 'm4_define([AT_PACKAGE_STRING],' && \ + echo ' [$(PACKAGE_STRING)])' && \ + echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \ + echo ' [$(PACKAGE_BUGREPORT)])'; \ + echo 'm4_define([AT_PACKAGE_URL],' && \ + echo ' [$(PACKAGE_URL)])'; \ + } >'$(srcdir)/package.m4' + +EXTRA_DIST = \ + testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \ + rlcmac/RLCMACTest.ok rlcmac/RLCMACTest.err + +DISTCLEANFILES = atconfig + +TESTSUITE = $(srcdir)/testsuite # Python testing if ENABLE_VTY_TESTS @@ -12,5 +45,20 @@ python-tests: $(BUILT_SOURCES) @echo "Not running python-based tests (determined at configure-time)" endif -check-local: $(BUILT_SOURCES) +check-local: $(BUILT_SOURCES) $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) $(MAKE) $(AM_MAKEFLAGS) python-tests + +installcheck-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \ + $(TESTSUITEFLAGS) + +clean-local: + test ! -f '$(TESTSUITE)' || \ + $(SHELL) '$(TESTSUITE)' --clean + +AUTOM4TE = $(SHELL) $(top_srcdir)/missing --run autom4te +AUTOTEST = $(AUTOM4TE) --language=autotest +$(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4 + $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at + mv $@.tmp $@ diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp new file mode 100644 index 0000000..66bc53c --- /dev/null +++ b/tests/rlcmac/RLCMACTest.cpp @@ -0,0 +1,218 @@ +/* RLCMACTest.cpp + * + * Copyright (C) 2011 Ivan Klyuchnikov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + + +//#include +#include +#include +#include +#include "csn1.h" +#include "gsm_rlcmac.h" +extern "C" { +extern const struct log_info gprs_log_info; +#include "pcu_vty.h" +#include +#include +#include +} +using namespace std; + +void printSizeofRLCMAC() +{ + cout << "sizeof RlcMacUplink_t " << sizeof(RlcMacUplink_t) << endl; + cout << "sizeof Packet_Cell_Change_Failure_t " << sizeof(Packet_Cell_Change_Failure_t) << endl; + cout << "sizeof Packet_Control_Acknowledgement_t " << sizeof(Packet_Control_Acknowledgement_t) << endl; + cout << "sizeof Packet_Downlink_Ack_Nack_t " << sizeof(Packet_Downlink_Ack_Nack_t) << endl; + cout << "sizeof EGPRS_PD_AckNack_t " << sizeof(EGPRS_PD_AckNack_t) << endl; + cout << "sizeof Packet_Uplink_Dummy_Control_Block_t " << sizeof(Packet_Uplink_Dummy_Control_Block_t) << endl; + cout << "sizeof Packet_Measurement_Report_t " << sizeof(Packet_Measurement_Report_t) << endl; + cout << "sizeof Packet_Resource_Request_t " << sizeof(Packet_Resource_Request_t) << endl; + cout << "sizeof Packet_Mobile_TBF_Status_t " << sizeof(Packet_Mobile_TBF_Status_t) << endl; + cout << "sizeof Packet_PSI_Status_t " << sizeof(Packet_PSI_Status_t) << endl; + cout << "sizeof Packet_Enh_Measurement_Report_t " << sizeof(Packet_Enh_Measurement_Report_t) << endl; + cout << "sizeof Packet_Cell_Change_Notification_t " << sizeof(Packet_Cell_Change_Notification_t) << endl; + cout << "sizeof Packet_SI_Status_t " << sizeof(Packet_SI_Status_t) << endl; + cout << "sizeof Additional_MS_Rad_Access_Cap_t " << sizeof(Additional_MS_Rad_Access_Cap_t) << endl; + cout << "sizeof Packet_Pause_t " << sizeof(Packet_Pause_t) << endl; + + cout << "sizeof RlcMacDownlink_t " << sizeof(RlcMacDownlink_t) << endl; + cout << "sizeof Packet_Access_Reject_t " << sizeof(Packet_Access_Reject_t) << endl; + cout << "sizeof Packet_Cell_Change_Order_t " << sizeof(Packet_Cell_Change_Order_t) << endl; + cout << "sizeof Packet_Downlink_Assignment_t " << sizeof(Packet_Downlink_Assignment_t) << endl; + cout << "sizeof Packet_Measurement_Order_Reduced_t " << sizeof(Packet_Measurement_Order_Reduced_t) << endl; + cout << "sizeof Packet_Neighbour_Cell_Data_t " << sizeof(Packet_Neighbour_Cell_Data_t) << endl; + cout << "sizeof Packet_Serving_Cell_Data_t " << sizeof(Packet_Serving_Cell_Data_t) << endl; + cout << "sizeof Packet_Paging_Request_t " << sizeof(Packet_Paging_Request_t) << endl; + cout << "sizeof Packet_PDCH_Release_t " << sizeof(Packet_PDCH_Release_t) << endl; + cout << "sizeof Packet_Polling_Request_t " << sizeof(Packet_Polling_Request_t) << endl; + cout << "sizeof Packet_Power_Control_Timing_Advance_t " << sizeof(Packet_Power_Control_Timing_Advance_t) << endl; + cout << "sizeof Packet_PRACH_Parameters_t " << sizeof(Packet_PRACH_Parameters_t) << endl; + cout << "sizeof Packet_Queueing_Notification_t " << sizeof(Packet_Queueing_Notification_t) << endl; + cout << "sizeof Packet_Timeslot_Reconfigure_t " << sizeof(Packet_Timeslot_Reconfigure_t) << endl; + cout << "sizeof Packet_TBF_Release_t " << sizeof(Packet_TBF_Release_t) << endl; + cout << "sizeof Packet_Uplink_Ack_Nack_t " << sizeof(Packet_Uplink_Ack_Nack_t) << endl; + cout << "sizeof Packet_Uplink_Assignment_t " << sizeof(Packet_Uplink_Assignment_t) << endl; + cout << "sizeof Packet_Cell_Change_Continue_t " << sizeof(Packet_Cell_Change_Continue_t) << endl; + cout << "sizeof Packet_Handover_Command_t " << sizeof(Packet_Handover_Command_t) << endl; + cout << "sizeof Packet_PhysicalInformation_t " << sizeof(Packet_PhysicalInformation_t) << endl; + cout << "sizeof Packet_Downlink_Dummy_Control_Block_t " << sizeof(Packet_Downlink_Dummy_Control_Block_t) << endl; + cout << "sizeof PSI1_t " << sizeof(PSI1_t) << endl; + cout << "sizeof PSI2_t " << sizeof(PSI2_t) << endl; + cout << "sizeof PSI3_t " << sizeof(PSI3_t) << endl; + cout << "sizeof PSI3_BIS_t " << sizeof(PSI3_BIS_t) << endl; + cout << "sizeof PSI4_t " << sizeof(PSI4_t) << endl; + cout << "sizeof PSI13_t " << sizeof(PSI13_t) << endl; + cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl; +} + +void testRlcMacDownlink() +{ + struct bitvec *resultVector = bitvec_alloc(23); + bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + + std::string testData[] = { + "4e082500e3f1a81d080820800b2b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment + "48282407a6a074227201000b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment + "47240c00400000000000000079eb2ac9402b2b2b2b2b2b", // Packet Uplink Ack Nack + "47283c367513ba333004242b2b2b2b2b2b2b2b2b2b2b2b" // Packet Uplink Assignment + "4913e00850884013a8048b2b2b2b2b2b2b2b2b2b2b2b2b" + "412430007fffffffffffffffefd19c7ba12b2b2b2b2b2b" + "41942b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b" + }; + + int testDataSize = sizeof(testData)/sizeof(testData[0]); + + cout << " DOWNLINK " << endl; + for (int i = 0; i < testDataSize; i++) + { + bitvec *vector = bitvec_alloc(23); + bitvec_unhex(vector, testData[i].c_str()); + cout << "vector1 = "; + for (int i = 0; i < 23; i++) + { + cout << hex << (unsigned)*(vector->data + i); + } + cout << endl; + RlcMacDownlink_t * data = (RlcMacDownlink_t *)malloc(sizeof(RlcMacDownlink_t)); + cout << "=========Start DECODE===========" << endl; + decode_gsm_rlcmac_downlink(vector, data); + cout << "+++++++++Finish DECODE++++++++++" << endl; + cout << "=========Start ENCODE=============" << endl; + encode_gsm_rlcmac_downlink(resultVector, data); + cout << "+++++++++Finish ENCODE+++++++++++" << endl; + cout << "vector1 = "; + for (int i = 0; i < 23; i++) + { + cout << (unsigned)*(vector->data + i); + } + cout << endl; + cout << "vector2 = "; + for (int i = 0; i < 23; i++) + { + cout << (unsigned)*(resultVector->data + i); + } + cout << endl; + if (memcmp(vector->data, resultVector->data, 23) == 0) + { + cout << "vector1 == vector2 : TRUE" << endl; + } + else + { + cout << "vector1 == vector2 : FALSE" << endl; + } + bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + bitvec_free(vector); + free(data); + } + + bitvec_free(resultVector); +} + + +void testRlcMacUplink() +{ + struct bitvec *resultVector = bitvec_alloc(23); + bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + + std::string testData[] = { + "400e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Dummy Control Block + "400b8020000000000000002480e00b2b2b2b2b2b2b2b2b", // Packet Downlink Ack/Nack + "4016713dc094270ca2ae57ef909006aa0fc0001f80222b" // Packet Resource Request + "400a9020000000000000003010012a0800132b2b2b2b2b" + }; + + int testDataSize = sizeof(testData)/sizeof(testData[0]); + + + cout << " UPLINK " << endl; + for (int i = 0; i < testDataSize; i++) + { + bitvec *vector = bitvec_alloc(23); + bitvec_unhex(vector, testData[i].c_str()); + cout << "vector1 = "; + for (int i = 0; i < 23; i++) + { + cout << hex << (unsigned)*(vector->data + i); + } + cout << endl; + RlcMacUplink_t * data = (RlcMacUplink_t *)malloc(sizeof(RlcMacUplink_t)); + cout << "=========Start DECODE===========" << endl; + decode_gsm_rlcmac_uplink(vector, data); + cout << "+++++++++Finish DECODE++++++++++" << endl; + cout << "=========Start ENCODE=============" << endl; + encode_gsm_rlcmac_uplink(resultVector, data); + cout << "+++++++++Finish ENCODE+++++++++++" << endl; + cout << "vector1 = "; + for (int i = 0; i < 23; i++) + { + cout << (unsigned)*(vector->data + i); + } + cout << endl; + cout << "vector2 = "; + for (int i = 0; i < 23; i++) + { + cout << (unsigned)*(resultVector->data + i); + } + cout << endl; + if (memcmp(vector->data, resultVector->data, 23) == 0) + { + cout << "vector1 == vector2 : TRUE" << endl; + } + else + { + cout << "vector1 == vector2 : FALSE" << endl; + } + bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + bitvec_free(vector); + free(data); + } + + bitvec_free(resultVector); +} + +int main(int argc, char *argv[]) +{ + osmo_init_logging(&gprs_log_info); + + //printSizeofRLCMAC(); + testRlcMacDownlink(); + testRlcMacUplink(); + +} diff --git a/tests/rlcmac/RLCMACTest.err b/tests/rlcmac/RLCMACTest.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/rlcmac/RLCMACTest.ok b/tests/rlcmac/RLCMACTest.ok new file mode 100644 index 0000000..a931636 --- /dev/null +++ b/tests/rlcmac/RLCMACTest.ok @@ -0,0 +1,58 @@ + DOWNLINK +vector1 = 4e8250e3f1a81d882080b2b2b2b2b2b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 4e8250e3f1a81d882080b2b2b2b2b2b2b2b2b2b2b +vector2 = 4e8250e3f1a81d882080b2b2b2b2b2b2b2b2b2b2b +vector1 == vector2 : TRUE +vector1 = 4828247a6a074227210b2b2b2b2b2b2b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 4828247a6a074227210b2b2b2b2b2b2b2b2b2b2b2b +vector2 = 4828247a6a074227210b2b2b2b2b2b2b2b2b2b2b2b +vector1 == vector2 : TRUE +vector1 = 4724c040000000079eb2ac9402b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 4724c040000000079eb2ac9402b2b2b2b2b2b +vector2 = 4724c040000000079eb2ac9402b2b2b2b2b2b +vector1 == vector2 : TRUE +vector1 = 47283c367513ba33304242b2b2b2b2b2b2b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 47283c367513ba33304242b2b2b2b2b2b2b2b2b2b2b2b +vector2 = 47283c367513ba33304242b2b2b2b2b2b2b2b2b2b2b2b +vector1 == vector2 : TRUE + UPLINK +vector1 = 40e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 40e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b +vector2 = 40e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b +vector1 == vector2 : TRUE +vector1 = 40b802000000002480e0b2b2b2b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 40b802000000002480e0b2b2b2b2b2b2b2b2b +vector2 = 40b802000000002480e0b2b2b2b2b2b2b2b2b +vector1 == vector2 : TRUE +vector1 = 4016713dc09427ca2ae57ef90906aafc001f80222b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 4016713dc09427ca2ae57ef90906aafc001f80222b +vector2 = 4016713dc09427ca2ae57ef90906aafc001f80222b +vector1 == vector2 : TRUE diff --git a/tests/testsuite.at b/tests/testsuite.at new file mode 100644 index 0000000..824c274 --- /dev/null +++ b/tests/testsuite.at @@ -0,0 +1,10 @@ +AT_INIT +AT_BANNER([Regression tests]) + + +AT_SETUP([rlcmac]) +AT_KEYWORDS([rlcmac]) +cat $abs_srcdir/rlcmac/RLCMACTest.ok > expout +cat $abs_srcdir/rlcmac/RLCMACTest.err > experr +AT_CHECK([$abs_top_builddir/tests/rlcmac/RLCMACTest], [0], [expout], [experr]) +AT_CLEANUP -- 1.8.3.2 From hfreyther at sysmocom.de Tue Jul 30 19:26:44 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 21:26:44 +0200 Subject: [PATCH 6/9] bitvector: Address compiler warnings about unsigned/signed In-Reply-To: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1375212407-2209-6-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther Fixes: bitvector.cpp: In function 'int bitvec_pack(bitvec*, uint8_t*)': bitvector.cpp:53:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] bitvector.cpp: In function 'int bitvec_unpack(bitvec*, uint8_t*)': bitvector.cpp:63:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] bitvector.cpp: In function 'uint64_t bitvec_read_field(bitvec*, unsigned int&, unsigned int)': bitvector.cpp:91:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] bitvector.cpp: In function 'int bitvec_write_field(bitvec*, unsigned int&, uint64_t, unsigned int)': bitvector.cpp:108:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] --- src/bitvector.cpp | 13 +++++++------ src/bitvector.h | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bitvector.cpp b/src/bitvector.cpp index 36ef798..43feebc 100644 --- a/src/bitvector.cpp +++ b/src/bitvector.cpp @@ -47,9 +47,9 @@ void bitvec_free(struct bitvec *bv) talloc_free(bv); } -int bitvec_pack(struct bitvec *bv, uint8_t *buffer) +unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer) { - int i = 0; + unsigned int i = 0; for (i = 0; i < bv->data_len; i++) { buffer[i] = bv->data[i]; @@ -57,9 +57,9 @@ int bitvec_pack(struct bitvec *bv, uint8_t *buffer) return i; } -int bitvec_unpack(struct bitvec *bv, uint8_t *buffer) +unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer) { - int i = 0; + unsigned int i = 0; for (i = 0; i < bv->data_len; i++) { bv->data[i] = buffer[i]; @@ -84,7 +84,7 @@ int bitvec_unhex(struct bitvec *bv, const char* src) uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len) { - int i; + unsigned int i; uint64_t ui = 0; bv->cur_bit = read_index; @@ -103,7 +103,8 @@ uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len) { - int i, rc; + unsigned int i; + int rc; bv->cur_bit = write_index; for (i = 0; i < len; i++) { int bit = 0; diff --git a/src/bitvector.h b/src/bitvector.h index 7409d55..36bdbab 100644 --- a/src/bitvector.h +++ b/src/bitvector.h @@ -35,8 +35,8 @@ extern "C" { struct bitvec *bitvec_alloc(unsigned size); void bitvec_free(struct bitvec *bv); int bitvec_unhex(struct bitvec *bv, const char* src); -int bitvec_pack(struct bitvec *bv, uint8_t *buffer); -int bitvec_unpack(struct bitvec *bv, uint8_t *buffer); +unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer); +unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer); uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len); int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len); -- 1.8.3.2 From hfreyther at sysmocom.de Tue Jul 30 19:26:43 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Tue, 30 Jul 2013 21:26:43 +0200 Subject: [PATCH 5/9] pcu_l1_if.cpp: Remove unused method and comment In-Reply-To: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> Message-ID: <1375212407-2209-5-git-send-email-hfreyther@sysmocom.de> From: Holger Hans Peter Freyther pcu_l1_if.cpp:195:13: warning: 'void pcu_l1if_tx_bcch(uint8_t*, int)' defined but not used [-Wunused-function] --- src/pcu_l1_if.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 037cf60..4452f0f 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -191,12 +191,6 @@ void pcu_l1if_tx_pch(bitvec * block, int plen, char *imsi) pcu_tx_data_req(0, 0, PCU_IF_SAPI_PCH, 0, 0, 0, data, 23+3); } -// FIXME: remove this, when changed from c++ to c. -static void pcu_l1if_tx_bcch(uint8_t *data, int len) -{ - pcu_tx_data_req(0, 0, PCU_IF_SAPI_BCCH, 0, 0, 0, data, len); -} - extern "C" int pcu_rx_data_ind_pdtch(uint8_t trx, uint8_t ts, uint8_t *data, uint8_t len, uint32_t fn, int8_t rssi) { -- 1.8.3.2 From alexander.chemeris at gmail.com Wed Jul 31 05:48:36 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Wed, 31 Jul 2013 09:48:36 +0400 Subject: [PATCH 8/9] tests: Create tests directory and move the VTY testing into there In-Reply-To: <1375212407-2209-8-git-send-email-hfreyther@sysmocom.de> References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> <1375212407-2209-8-git-send-email-hfreyther@sysmocom.de> Message-ID: Hi Holger, I don't see real files being moved (osmotestvty.py and osmotestconfig.py). Probably you forgot to stage them? On Tue, Jul 30, 2013 at 11:26 PM, Holger Hans Peter Freyther wrote: > From: Holger Hans Peter Freyther > > --- > Makefile.am | 13 +------------ > configure.ac | 1 + > tests/Makefile.am | 16 ++++++++++++++++ > 3 files changed, 18 insertions(+), 12 deletions(-) > create mode 100644 tests/Makefile.am > > diff --git a/Makefile.am b/Makefile.am > index e23a40f..4cbc114 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -1,16 +1,5 @@ > AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 > > -SUBDIRS = src examples > +SUBDIRS = src examples tests > EXTRA_DIST = osmoappdesc.py > > -if ENABLE_VTY_TESTS > -python-tests: $(BUILT_SOURCES) > - osmotestvty.py -p $(top_srcdir) -w $(builddir) -v > - osmotestconfig.py -p $(top_srcdir) -w $(builddir) -v > -else > -python-tests: $(BUILT_SOURCES) > - @echo "Not running python-based tests (determined at configure-time)" > -endif > - > -check-local: $(BUILT_SOURCES) > - $(MAKE) $(AM_MAKEFLAGS) python-tests > diff --git a/configure.ac b/configure.ac > index 6510bf4..58cbc35 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -60,4 +60,5 @@ AM_CONDITIONAL(ENABLE_VTY_TESTS, test "x$enable_vty_tests" = "xyes") > AC_OUTPUT( > src/Makefile > examples/Makefile > + tests/Makefile > Makefile) > diff --git a/tests/Makefile.am b/tests/Makefile.am > new file mode 100644 > index 0000000..7581ea9 > --- /dev/null > +++ b/tests/Makefile.am > @@ -0,0 +1,16 @@ > + > + > + > +# Python testing > +if ENABLE_VTY_TESTS > +python-tests: $(BUILT_SOURCES) > + osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v > + osmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v > + > +else > +python-tests: $(BUILT_SOURCES) > + @echo "Not running python-based tests (determined at configure-time)" > +endif > + > +check-local: $(BUILT_SOURCES) > + $(MAKE) $(AM_MAKEFLAGS) python-tests > -- > 1.8.3.2 > > -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru From hfreyther at sysmocom.de Wed Jul 31 06:13:31 2013 From: hfreyther at sysmocom.de (Holger Hans Peter Freyther) Date: Wed, 31 Jul 2013 08:13:31 +0200 Subject: [PATCH 8/9] tests: Create tests directory and move the VTY testing into there In-Reply-To: References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> <1375212407-2209-8-git-send-email-hfreyther@sysmocom.de> Message-ID: <20130731061331.GD32743@xiaoyu.lan> On Wed, Jul 31, 2013 at 09:48:36AM +0400, Alexander Chemeris wrote: > Hi Holger, > > I don't see real files being moved (osmotestvty.py and > osmotestconfig.py). Probably you forgot to stage them? I think I didn't miss a file. The osmotestvty/osmotestconfig are two installed scripts and they read the app config from the abs_topsrcdir. It is mostly there to start using the test/ directory for tests. E.g RLCMACTest is moved there, the emulator PCU will be there and other tests while I move code around. thanks for taking a look holger -- - Holger Freyther http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Schivelbeiner Str. 5 * 10439 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte From alexander.chemeris at gmail.com Wed Jul 31 06:20:00 2013 From: alexander.chemeris at gmail.com (Alexander Chemeris) Date: Wed, 31 Jul 2013 10:20:00 +0400 Subject: [PATCH 8/9] tests: Create tests directory and move the VTY testing into there In-Reply-To: <20130731061331.GD32743@xiaoyu.lan> References: <1375212407-2209-1-git-send-email-hfreyther@sysmocom.de> <1375212407-2209-8-git-send-email-hfreyther@sysmocom.de> <20130731061331.GD32743@xiaoyu.lan> Message-ID: On Wed, Jul 31, 2013 at 10:13 AM, Holger Hans Peter Freyther wrote: > On Wed, Jul 31, 2013 at 09:48:36AM +0400, Alexander Chemeris wrote: > > Hi Holger, > > > > I don't see real files being moved (osmotestvty.py and > > osmotestconfig.py). Probably you forgot to stage them? > > I think I didn't miss a file. The osmotestvty/osmotestconfig > are two installed scripts and they read the app config from > the abs_topsrcdir. It is mostly there to start using the > test/ directory for tests. E.g RLCMACTest is moved there, the > emulator PCU will be there and other tests while I move code > around. Ok, sorry for false alert. Looked through this from a tablet and assumed that all files are in-tree. -- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ??? ??????? http://fairwaves.ru