bsc_api: Rename lchan_for_subscr to connection_for_subscr and update code
With handover and late/early assignment there might be two channels for one subscriber and only the BSC knows which one to use, so use the gsm_subscriber_connection everywhere...
This commit is contained in:
parent
ea01ca764f
commit
b2be195b50
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "gsm_subscriber.h"
|
||||
|
||||
struct gsm_subscriber_connection;
|
||||
|
||||
/* Special allocator for C0 of BTS */
|
||||
struct gsm_bts_trx_ts *ts_c0_alloc(struct gsm_bts *bts,
|
||||
enum gsm_phys_chan_config pchan);
|
||||
|
@ -35,7 +37,7 @@ struct gsm_bts_trx_ts *ts_alloc(struct gsm_bts *bts,
|
|||
void ts_free(struct gsm_bts_trx_ts *ts);
|
||||
|
||||
/* Find an allocated channel for a specified subscriber */
|
||||
struct gsm_lchan *lchan_for_subscr(struct gsm_subscriber *subscr);
|
||||
struct gsm_subscriber_connection *connection_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);
|
||||
|
|
|
@ -396,7 +396,7 @@ static struct gsm_lchan* lchan_find(struct gsm_bts *bts, struct gsm_subscriber *
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct gsm_lchan *lchan_for_subscr(struct gsm_subscriber *subscr)
|
||||
struct gsm_subscriber_connection *connection_for_subscr(struct gsm_subscriber *subscr)
|
||||
{
|
||||
struct gsm_bts *bts;
|
||||
struct gsm_network *net = subscr->net;
|
||||
|
@ -405,7 +405,7 @@ struct gsm_lchan *lchan_for_subscr(struct gsm_subscriber *subscr)
|
|||
llist_for_each_entry(bts, &net->bts_list, list) {
|
||||
lchan = lchan_find(bts, subscr);
|
||||
if (lchan)
|
||||
return lchan;
|
||||
return &lchan->conn;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -2798,7 +2798,7 @@ int mncc_send(struct gsm_network *net, int msg_type, void *arg)
|
|||
{
|
||||
int i, rc = 0;
|
||||
struct gsm_trans *trans = NULL, *transt;
|
||||
struct gsm_lchan *lchan = NULL;
|
||||
struct gsm_subscriber_connection *conn = NULL;
|
||||
struct gsm_bts *bts = NULL;
|
||||
struct gsm_mncc *data = arg, rel;
|
||||
|
||||
|
@ -2903,10 +2903,10 @@ int mncc_send(struct gsm_network *net, int msg_type, void *arg)
|
|||
return -ENOMEM;
|
||||
}
|
||||
/* Find lchan */
|
||||
lchan = lchan_for_subscr(subscr);
|
||||
conn = connection_for_subscr(subscr);
|
||||
|
||||
/* If subscriber has no lchan */
|
||||
if (!lchan) {
|
||||
if (!conn) {
|
||||
/* find transaction with this subscriber already paging */
|
||||
llist_for_each_entry(transt, &net->trans_list, entry) {
|
||||
/* Transaction of our lchan? */
|
||||
|
@ -2932,16 +2932,16 @@ int mncc_send(struct gsm_network *net, int msg_type, void *arg)
|
|||
return 0;
|
||||
}
|
||||
/* Assign lchan */
|
||||
trans->conn = &lchan->conn;
|
||||
trans->conn = conn;
|
||||
use_subscr_con(trans->conn);
|
||||
subscr_put(subscr);
|
||||
}
|
||||
|
||||
if (trans->conn)
|
||||
lchan = trans->conn->lchan;
|
||||
conn = trans->conn;
|
||||
|
||||
/* if paging did not respond yet */
|
||||
if (!lchan) {
|
||||
if (!conn) {
|
||||
DEBUGP(DCC, "(bts - trx - ts - ti -- sub %s) "
|
||||
"Received '%s' from MNCC in paging state\n",
|
||||
(trans->subscr)?(trans->subscr->extension):"-",
|
||||
|
@ -2959,7 +2959,7 @@ int mncc_send(struct gsm_network *net, int msg_type, void *arg)
|
|||
|
||||
DEBUGP(DCC, "(bts %d trx %d ts %d ti %02x sub %s) "
|
||||
"Received '%s' from MNCC in state %d (%s)\n",
|
||||
lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
|
||||
conn->bts->nr, conn->lchan->ts->trx->nr, conn->lchan->ts->nr,
|
||||
trans->transaction_id,
|
||||
(trans->conn->subscr)?(trans->conn->subscr->extension):"-",
|
||||
get_mncc_name(msg_type), trans->cc.state,
|
||||
|
|
|
@ -1143,14 +1143,14 @@ static int paging_cb_send_sms(unsigned int hooknum, unsigned int event,
|
|||
int gsm411_send_sms_subscr(struct gsm_subscriber *subscr,
|
||||
struct gsm_sms *sms)
|
||||
{
|
||||
struct gsm_lchan *lchan;
|
||||
struct gsm_subscriber_connection *conn;
|
||||
|
||||
/* check if we already have an open lchan to the subscriber.
|
||||
* if yes, send the SMS this way */
|
||||
lchan = lchan_for_subscr(subscr);
|
||||
if (lchan) {
|
||||
use_subscr_con(&lchan->conn);
|
||||
return gsm411_send_sms_lchan(&lchan->conn, sms);
|
||||
conn = connection_for_subscr(subscr);
|
||||
if (conn) {
|
||||
use_subscr_con(conn);
|
||||
return gsm411_send_sms_lchan(conn, sms);
|
||||
}
|
||||
|
||||
/* if not, we have to start paging */
|
||||
|
@ -1162,7 +1162,7 @@ static int subscr_sig_cb(unsigned int subsys, unsigned int signal,
|
|||
void *handler_data, void *signal_data)
|
||||
{
|
||||
struct gsm_subscriber *subscr;
|
||||
struct gsm_lchan *lchan;
|
||||
struct gsm_subscriber_connection *conn;
|
||||
struct gsm_sms *sms;
|
||||
|
||||
switch (signal) {
|
||||
|
@ -1170,14 +1170,14 @@ static int subscr_sig_cb(unsigned int subsys, unsigned int signal,
|
|||
/* A subscriber has attached. Check if there are
|
||||
* any pending SMS for him to be delivered */
|
||||
subscr = signal_data;
|
||||
lchan = lchan_for_subscr(subscr);
|
||||
if (!lchan)
|
||||
conn = connection_for_subscr(subscr);
|
||||
if (!conn)
|
||||
break;
|
||||
sms = db_sms_get_unsent_for_subscr(subscr);
|
||||
if (!sms)
|
||||
break;
|
||||
use_subscr_con(&lchan->conn);
|
||||
gsm411_send_sms_lchan(&lchan->conn, sms);
|
||||
use_subscr_con(conn);
|
||||
gsm411_send_sms_lchan(conn, sms);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -68,16 +68,16 @@ static int subscr_sig_cb(unsigned int subsys, unsigned int signal,
|
|||
void *handler_data, void *signal_data)
|
||||
{
|
||||
struct gsm_subscriber *subscr;
|
||||
struct gsm_lchan *lchan;
|
||||
struct gsm_subscriber_connection *conn;
|
||||
|
||||
switch (signal) {
|
||||
case S_SUBSCR_ATTACHED:
|
||||
/* A subscriber has attached. */
|
||||
subscr = signal_data;
|
||||
lchan = lchan_for_subscr(subscr);
|
||||
if (!lchan)
|
||||
conn = connection_for_subscr(subscr);
|
||||
if (!conn)
|
||||
break;
|
||||
send_rrlp_req(lchan);
|
||||
send_rrlp_req(&conn->lchan);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -128,15 +128,13 @@ int gsm_silent_call_start(struct gsm_subscriber *subscr, void *data, int type)
|
|||
/* end a silent call with a given subscriber */
|
||||
int gsm_silent_call_stop(struct gsm_subscriber *subscr)
|
||||
{
|
||||
struct gsm_lchan *lchan;
|
||||
struct gsm_subscriber_connection *conn;
|
||||
|
||||
lchan = lchan_for_subscr(subscr);
|
||||
if (!lchan)
|
||||
conn = connection_for_subscr(subscr);
|
||||
if (!conn)
|
||||
return -EINVAL;
|
||||
|
||||
/* did we actually establish a silent call for this guy? */
|
||||
conn = &lchan->conn;
|
||||
if (!conn->silent_call)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
@ -99,12 +99,12 @@ unauth:
|
|||
subscr->authorized = 0;
|
||||
db_sync_subscriber(subscr);
|
||||
if (rc) {
|
||||
struct gsm_lchan *lchan = lchan_for_subscr(subscr);
|
||||
if (lchan) {
|
||||
struct gsm_subscriber_connection *conn = connection_for_subscr(subscr);
|
||||
if (conn) {
|
||||
u_int8_t auth_rand[16];
|
||||
/* kick the subscriber off the network */
|
||||
gsm48_tx_mm_auth_req(&lchan->conn, auth_rand, 0);
|
||||
gsm48_tx_mm_auth_rej(&lchan->conn);
|
||||
gsm48_tx_mm_auth_req(conn, auth_rand, 0);
|
||||
gsm48_tx_mm_auth_rej(conn);
|
||||
/* FIXME: close the channel early ?*/
|
||||
//gsm48_send_rr_Release(lchan);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ static int token_sms_cb(unsigned int subsys, unsigned int signal,
|
|||
void *handler_data, void *signal_data)
|
||||
{
|
||||
struct gsm_sms *sms = signal_data;
|
||||
struct gsm_lchan *lchan;
|
||||
struct gsm_subscriber_connection *conn;
|
||||
u_int8_t auth_rand[16];
|
||||
|
||||
|
||||
|
@ -136,11 +136,11 @@ static int token_sms_cb(unsigned int subsys, unsigned int signal,
|
|||
return 0;
|
||||
|
||||
|
||||
lchan = lchan_for_subscr(sms->receiver);
|
||||
if (lchan) {
|
||||
conn = connection_for_subscr(sms->receiver);
|
||||
if (conn) {
|
||||
/* kick the subscriber off the network */
|
||||
gsm48_tx_mm_auth_req(&lchan->conn, auth_rand, 0);
|
||||
gsm48_tx_mm_auth_rej(&lchan->conn);
|
||||
gsm48_tx_mm_auth_req(conn, auth_rand, 0);
|
||||
gsm48_tx_mm_auth_rej(conn);
|
||||
/* FIXME: close the channel early ?*/
|
||||
//gsm48_send_rr_Release(lchan);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue