diff options
Diffstat (limited to 'openbsc/src/bsc_msc_grace.c')
-rw-r--r-- | openbsc/src/bsc_msc_grace.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/openbsc/src/bsc_msc_grace.c b/openbsc/src/bsc_msc_grace.c index bd95be2e2..91dfcba32 100644 --- a/openbsc/src/bsc_msc_grace.c +++ b/openbsc/src/bsc_msc_grace.c @@ -21,6 +21,7 @@ #include <openbsc/bsc_msc_grace.h> #include <openbsc/bsc_msc_rf.h> +#include <openbsc/gsm_04_80.h> #include <openbsc/signal.h> int bsc_grace_allow_new_connection(struct gsm_network *network) @@ -28,6 +29,22 @@ int bsc_grace_allow_new_connection(struct gsm_network *network) return network->rf->policy == S_RF_ON; } +static int handle_sub(struct gsm_lchan *lchan, const char *text) +{ + /* only send it to TCH */ + if (lchan->type != GSM_LCHAN_TCH_H && lchan->type != GSM_LCHAN_TCH_F) + return -1; + + /* only when active */ + if (lchan->state != LCHAN_S_ACTIVE) + return -1; + + gsm0480_send_ussdNotify(lchan, 0, text); + gsm0480_send_releaseComplete(lchan); + + 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 @@ -35,6 +52,24 @@ int bsc_grace_allow_new_connection(struct gsm_network *network) */ static int handle_grace(struct gsm_network *network) { + int ts_nr, lchan_nr; + struct gsm_bts *bts; + struct gsm_bts_trx *trx; + + if (!network->ussd_grace_txt) + 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], + network->ussd_grace_txt); + } + } + } + } return 0; } |