2010-09-15 16:20:56 +00:00
|
|
|
/*
|
2013-01-07 16:30:13 +00:00
|
|
|
* (C) 2010-2013 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* (C) 2010-2013 by On-Waves
|
2010-09-15 16:20:56 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2010-09-15 16:20:56 +00:00
|
|
|
* (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
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2010-09-15 16:20:56 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-09-15 16:20:56 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-04 13:15:32 +00:00
|
|
|
#include <osmocom/bsc/osmo_bsc_grace.h>
|
|
|
|
#include <osmocom/bsc/osmo_bsc_rf.h>
|
|
|
|
#include <osmocom/bsc/bsc_msc_data.h>
|
|
|
|
#include <osmocom/bsc/gsm_04_80.h>
|
|
|
|
#include <osmocom/bsc/bsc_subscriber.h>
|
|
|
|
#include <osmocom/bsc/paging.h>
|
|
|
|
#include <osmocom/bsc/signal.h>
|
2010-09-15 16:20:56 +00:00
|
|
|
|
2012-08-30 14:43:28 +00:00
|
|
|
int bsc_grace_allow_new_connection(struct gsm_network *network, struct gsm_bts *bts)
|
2010-09-15 16:20:56 +00:00
|
|
|
{
|
2013-01-07 16:30:13 +00:00
|
|
|
if (bts->excl_from_rf_lock)
|
2012-08-30 14:43:28 +00:00
|
|
|
return 1;
|
2011-08-15 13:53:00 +00:00
|
|
|
return network->bsc_data->rf_ctrl->policy == S_RF_ON;
|
2010-09-15 16:20:56 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 16:19:45 +00:00
|
|
|
|
add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.
Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).
Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.
During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.
Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.
Add bsc_subscr unit test.
Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-02-18 21:20:46 +00:00
|
|
|
static int normal_paging(struct bsc_subscr *subscr, int chan_needed,
|
|
|
|
struct bsc_msc_data *msc)
|
2013-01-07 16:30:13 +00:00
|
|
|
{
|
2015-04-01 16:28:04 +00:00
|
|
|
/* we can't page by lac.. we need to page everything */
|
|
|
|
if (msc->core_lac != -1) {
|
|
|
|
struct gsm_bts *bts;
|
|
|
|
|
|
|
|
llist_for_each_entry(bts, &msc->network->bts_list, list)
|
2017-12-11 14:21:48 +00:00
|
|
|
paging_request_bts(bts, subscr, chan_needed, msc);
|
2015-04-01 16:28:04 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-12-11 14:21:48 +00:00
|
|
|
return paging_request(msc->network, subscr, chan_needed, msc);
|
2015-04-01 16:19:45 +00:00
|
|
|
}
|
2013-01-07 16:30:13 +00:00
|
|
|
|
2018-01-09 16:50:56 +00:00
|
|
|
/* Return value is like paging_request_bts():
|
|
|
|
* returns 1 on success (one BTS was paged); 0 in case of error (e.g. TRX down) */
|
|
|
|
static int locked_paging_bts(struct gsm_bts *bts,
|
|
|
|
struct bsc_subscr *subscr,
|
|
|
|
int chan_needed,
|
|
|
|
struct bsc_msc_data *msc)
|
|
|
|
{
|
|
|
|
/* Return error if the BTS is not excluded from the lock. */
|
|
|
|
if (!bts->excl_from_rf_lock)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* in case of no lac patching is in place, check the BTS */
|
|
|
|
if (msc->core_lac == -1 && subscr->lac != bts->location_area_code)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return paging_request_bts(bts, subscr, chan_needed, msc);
|
|
|
|
}
|
|
|
|
|
add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.
Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).
Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.
During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.
Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.
Add bsc_subscr unit test.
Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-02-18 21:20:46 +00:00
|
|
|
static int locked_paging(struct bsc_subscr *subscr, int chan_needed,
|
|
|
|
struct bsc_msc_data *msc)
|
2015-04-01 16:19:45 +00:00
|
|
|
{
|
|
|
|
struct gsm_bts *bts = NULL;
|
2018-01-09 16:50:56 +00:00
|
|
|
int num_pages = 0;
|
2013-01-07 16:30:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if there is any BTS that is on for the given lac. Start
|
|
|
|
* with NULL and iterate through all bts.
|
2018-01-09 16:50:56 +00:00
|
|
|
* All other bts are either off or in the grace period.
|
2013-01-07 16:30:13 +00:00
|
|
|
*/
|
2018-01-09 16:50:56 +00:00
|
|
|
llist_for_each_entry(bts, &msc->network->bts_list, list)
|
|
|
|
num_pages += locked_paging_bts(bts, subscr, chan_needed, msc);
|
|
|
|
|
|
|
|
return num_pages;
|
2015-04-01 16:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-01-09 16:50:56 +00:00
|
|
|
* Page a subscriber in an MSC.
|
|
|
|
* \param[in] rf_policy if not S_RF_ON, page only BTSs which are not excluded from the RF lock
|
|
|
|
* \param[in] subscr subscriber we want to page
|
|
|
|
* \param[in] chan_needed value of the GSM0808_IE_CHANNEL_NEEDED IE
|
|
|
|
* \param[in] msc MSC which has issued this paging
|
|
|
|
* \param[in] bts if not NULL, page via this particular BTS
|
|
|
|
* \returns number of BTS on which we issued the paging
|
2015-04-01 16:19:45 +00:00
|
|
|
*/
|
add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.
Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).
Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.
During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.
Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.
Add bsc_subscr unit test.
Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-02-18 21:20:46 +00:00
|
|
|
int bsc_grace_paging_request(enum signal_rf rf_policy,
|
|
|
|
struct bsc_subscr *subscr,
|
|
|
|
int chan_needed,
|
2018-01-09 16:50:56 +00:00
|
|
|
struct bsc_msc_data *msc,
|
|
|
|
struct gsm_bts *bts)
|
2015-04-01 16:19:45 +00:00
|
|
|
{
|
2018-01-09 16:50:56 +00:00
|
|
|
if (bts) {
|
|
|
|
if (rf_policy == S_RF_ON)
|
|
|
|
return paging_request_bts(bts, subscr, chan_needed, msc);
|
|
|
|
return locked_paging_bts(bts, subscr, chan_needed, msc);
|
|
|
|
}
|
|
|
|
|
add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.
Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).
Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.
During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.
Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.
Add bsc_subscr unit test.
Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-02-18 21:20:46 +00:00
|
|
|
if (rf_policy == S_RF_ON)
|
2015-04-01 16:19:45 +00:00
|
|
|
return normal_paging(subscr, chan_needed, msc);
|
|
|
|
return locked_paging(subscr, chan_needed, msc);
|
2013-01-07 16:30:13 +00:00
|
|
|
}
|
|
|
|
|
2010-09-15 16:20:56 +00:00
|
|
|
static int handle_sub(struct gsm_lchan *lchan, const char *text)
|
|
|
|
{
|
|
|
|
struct gsm_subscriber_connection *conn;
|
|
|
|
|
|
|
|
/* only send it to TCH */
|
|
|
|
if (lchan->type != GSM_LCHAN_TCH_H && lchan->type != GSM_LCHAN_TCH_F)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* only send on the primary channel */
|
|
|
|
conn = lchan->conn;
|
|
|
|
if (!conn)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (conn->lchan != lchan)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* only when active */
|
|
|
|
if (lchan->state != LCHAN_S_ACTIVE)
|
|
|
|
return -1;
|
|
|
|
|
2016-05-10 10:50:31 +00:00
|
|
|
bsc_send_ussd_notify(conn, 0, text);
|
|
|
|
bsc_send_ussd_release_complete(conn);
|
2010-09-15 16:20:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The place to handle the grace mode. Right now we will send
|
|
|
|
* USSD messages to the subscriber, in the future we might start
|
|
|
|
* a timer to have different modes for the grace period.
|
|
|
|
*/
|
|
|
|
static int handle_grace(struct gsm_network *network)
|
|
|
|
{
|
|
|
|
int ts_nr, lchan_nr;
|
|
|
|
struct gsm_bts *bts;
|
|
|
|
struct gsm_bts_trx *trx;
|
|
|
|
|
2011-08-15 13:53:00 +00:00
|
|
|
if (!network->bsc_data->mid_call_txt)
|
2010-09-15 16:20:56 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
llist_for_each_entry(bts, &network->bts_list, list) {
|
|
|
|
llist_for_each_entry(trx, &bts->trx_list, list) {
|
|
|
|
for (ts_nr = 0; ts_nr < TRX_NR_TS; ++ts_nr) {
|
|
|
|
struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr];
|
|
|
|
for (lchan_nr = 0; lchan_nr < TS_MAX_LCHAN; ++lchan_nr) {
|
|
|
|
handle_sub(&ts->lchan[lchan_nr],
|
2011-08-15 13:53:00 +00:00
|
|
|
network->bsc_data->mid_call_txt);
|
2010-09-15 16:20:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_rf_signal(unsigned int subsys, unsigned int signal,
|
|
|
|
void *handler_data, void *signal_data)
|
|
|
|
{
|
|
|
|
struct rf_signal_data *sig;
|
|
|
|
|
|
|
|
if (subsys != SS_RF)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
sig = signal_data;
|
|
|
|
|
|
|
|
if (signal == S_RF_GRACE)
|
|
|
|
handle_grace(sig->net);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __attribute__((constructor)) void on_dso_load_grace(void)
|
|
|
|
{
|
2011-05-06 10:12:31 +00:00
|
|
|
osmo_signal_register_handler(SS_RF, handle_rf_signal, NULL);
|
2010-09-15 16:20:56 +00:00
|
|
|
}
|