From 1a6f79818e867e2d9ab684c6352142cb036c6889 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 9 Aug 2009 18:52:33 +0200 Subject: move search for existing lchan for subscriber to new function There's now a new function called 'lchan_for_subscr()' which can be used to determine if there is any existing lchan for this subscriber. --- openbsc/include/openbsc/chan_alloc.h | 3 +++ openbsc/src/chan_alloc.c | 15 +++++++++++++++ openbsc/src/gsm_04_08.c | 24 +++--------------------- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'openbsc') diff --git a/openbsc/include/openbsc/chan_alloc.h b/openbsc/include/openbsc/chan_alloc.h index d6d367c84..38855d1ee 100644 --- a/openbsc/include/openbsc/chan_alloc.h +++ b/openbsc/include/openbsc/chan_alloc.h @@ -37,6 +37,9 @@ void ts_free(struct gsm_bts_trx_ts *ts); /* Find an allocated channel */ struct gsm_lchan *lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr); +/* Find an allocated channel for a specified subscriber */ +struct gsm_lchan *lchan_for_subscr(struct gsm_subscriber *subscr); + /* Allocate a logical channel (SDCCH, TCH, ...) */ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type); diff --git a/openbsc/src/chan_alloc.c b/openbsc/src/chan_alloc.c index a66f70e8c..860355a02 100644 --- a/openbsc/src/chan_alloc.c +++ b/openbsc/src/chan_alloc.c @@ -269,3 +269,18 @@ struct gsm_lchan* lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr) return NULL; } + +struct gsm_lchan *lchan_for_subscr(struct gsm_subscriber *subscr) +{ + struct gsm_bts *bts; + struct gsm_network *net = subscr->net; + struct gsm_lchan *lchan; + + llist_for_each_entry(bts, &net->bts_list, list) { + lchan = lchan_find(bts, subscr); + if (lchan) + return lchan; + } + + return 0; +} diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c index b753e0d8d..3e307b15f 100644 --- a/openbsc/src/gsm_04_08.c +++ b/openbsc/src/gsm_04_08.c @@ -3375,13 +3375,11 @@ static struct downstate { int mncc_send(struct gsm_network *net, int msg_type, void *arg) { - int i, j, k, l, rc = 0; + int i, rc = 0; struct gsm_trans *trans = NULL, *transt; struct gsm_subscriber *subscr; - struct gsm_lchan *lchan = NULL, *lchant; + struct gsm_lchan *lchan = NULL; struct gsm_bts *bts = NULL; - struct gsm_bts_trx *trx; - struct gsm_bts_trx_ts *ts; struct gsm_mncc *data = arg, rel; /* handle special messages */ @@ -3464,23 +3462,7 @@ int mncc_send(struct gsm_network *net, int msg_type, void *arg) return -ENOMEM; } /* Find lchan */ - for (i = 0; i < net->num_bts; i++) { - bts = gsm_bts_num(net, i); - for (j = 0; j < bts->num_trx; j++) { - trx = gsm_bts_trx_num(bts, j); - for (k = 0; k < TRX_NR_TS; k++) { - ts = &trx->ts[k]; - for (l = 0; l < TS_MAX_LCHAN; l++) { - lchant = &ts->lchan[l]; - if (lchant->subscr == subscr) { - lchan = lchant; - break; - } - } - } - } - } - + lchan = lchan_for_subscr(subscr); /* If subscriber has no lchan */ if (!lchan) { /* find transaction with this subscriber already paging */ -- cgit v1.2.3