aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Freyther <zecke@selfish.org>2008-12-29 06:23:49 +0000
committerHolger Freyther <zecke@selfish.org>2008-12-29 06:23:49 +0000
commit3186bf209a6c692a521c92cce9d56b49032f4ed3 (patch)
treed34aacdd3a158b4dd85f5ade92abf27e9ba990ec
parent86f1812105880b5dc3cd9e882d57c0b506769aac (diff)
Add callback for allocated lchannels
Currently it is not possible to know for which tmsi the channel is going to be allocated. The bsc_hack will guess.. in the future it might be forced to ask for the tmsi after the channel has been opened...
-rw-r--r--include/openbsc/gsm_data.h4
-rw-r--r--src/abis_rsl.c12
-rw-r--r--src/bsc_hack.c24
3 files changed, 35 insertions, 5 deletions
diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h
index 8f21524eb..99634f4c1 100644
--- a/include/openbsc/gsm_data.h
+++ b/include/openbsc/gsm_data.h
@@ -84,6 +84,9 @@ struct gsm_lchan {
/* local end of a call, if any */
struct gsm_call call;
+
+ /* temporary user data, to be removed... and merged into gsm_call */
+ void *user_data;
};
#define BTS_TRX_F_ACTIVATED 0x0001
@@ -146,6 +149,7 @@ struct gsm_network {
struct gsm_subscriber *subscriber;
void (*update_request_accepted)(struct gsm_bts *, u_int32_t);
+ void (*channel_allocated)(struct gsm_lchan *bts, enum gsm_chreq_reason_t);
};
struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code,
diff --git a/src/abis_rsl.c b/src/abis_rsl.c
index 31b43c76b..03498e9fe 100644
--- a/src/abis_rsl.c
+++ b/src/abis_rsl.c
@@ -579,6 +579,7 @@ static int rsl_rx_chan_rqd(struct msgb *msg)
enum gsm_chreq_reason_t chreq_reason;
struct gsm_lchan *lchan;
u_int8_t rqd_ta;
+ int ret;
u_int16_t arfcn;
u_int8_t ts_number, subch;
@@ -599,10 +600,6 @@ static int rsl_rx_chan_rqd(struct msgb *msg)
lctype = get_ctype_by_chreq(bts, rqd_ref->ra);
chreq_reason = get_reason_by_chreq(bts, rqd_ref->ra);
- if (chreq_reason == GSM_CHREQ_REASON_PAG) {
- DEBUGP(DPAG, "CHAN RQD due PAG %d\n", lctype);
- }
-
/* check availability / allocate channel */
lchan = lchan_alloc(bts, lctype);
if (!lchan) {
@@ -636,8 +633,13 @@ static int rsl_rx_chan_rqd(struct msgb *msg)
DEBUGP(DRSL, "Activating ARFCN(%u) TS(%u) SS(%u) lctype %u chan_nr=0x%02x r%d\n",
arfcn, ts_number, subch, lchan->type, ia.chan_desc.chan_nr, chreq_reason);
+
/* send IMMEDIATE ASSIGN CMD on RSL to BTS (to send on CCCH to MS) */
- return rsl_imm_assign_cmd(bts, sizeof(ia), (u_int8_t *) &ia);
+ ret = rsl_imm_assign_cmd(bts, sizeof(ia), (u_int8_t *) &ia);
+
+ /* inform the bsc that a channel has been allocated */
+ if (bts->network->channel_allocated)
+ (*bts->network->channel_allocated)(lchan, chreq_reason);
}
static int abis_rsl_rx_cchan(struct msgb *msg)
diff --git a/src/bsc_hack.c b/src/bsc_hack.c
index e409c7290..1cf0731f4 100644
--- a/src/bsc_hack.c
+++ b/src/bsc_hack.c
@@ -50,6 +50,8 @@ static const char *database_name = "hlr.sqlite3";
/* forward declarations */
static void bsc_hack_update_request_accepted(struct gsm_bts *bts, u_int32_t assigned_tmi);
+static void bsc_hack_channel_allocated(struct gsm_lchan *chan,
+ enum gsm_chreq_reason_t reason);
/* The following definitions are for OM and NM packets that we cannot yet
@@ -640,6 +642,7 @@ static int bootstrap_network(void)
bts->location_area_code = 1;
bts->trx[0].arfcn = HARDCODED_ARFCN;
gsmnet->update_request_accepted = bsc_hack_update_request_accepted;
+ gsmnet->channel_allocated = bsc_hack_channel_allocated;
if (mi_setup(bts, 0, mi_cb) < 0)
return -EIO;
@@ -812,6 +815,27 @@ static void bsc_hack_update_request_accepted(struct gsm_bts *bts, u_int32_t tmsi
schedule_timer(&station_timer, 1, 0);
}
+static void bsc_hack_channel_allocated(struct gsm_lchan *chan,
+ enum gsm_chreq_reason_t chreq_reason)
+{
+ struct pending_registered_station *station;
+ if (chreq_reason != GSM_CHREQ_REASON_PAG)
+ return;
+
+ if (llist_empty(&pending_stations)) {
+ DEBUGP(DPAG, "Channel allocated for pag but not waitin for it\n");
+ return;
+ }
+
+ station = (struct pending_registered_station*) pending_stations.next;
+
+ DEBUGP(DPAG, "CHAN RQD due PAG %d on %d for %u\n", chan->type, chan->nr, station->tmsi);
+
+ /* allocate some token in the chan for us */
+ chan->user_data = (void*)station->tmsi;
+ del_timer(&pag_timer);
+}
+
int main(int argc, char **argv)
{
/* parse options */