aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/bsc_api.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-06-28 15:47:12 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-06-28 16:12:39 +0800
commit2412a07965ace5fc425b401438d21ff86ceeb2df (patch)
tree43f862deafccf9500b8f81621862a708b144f6c7 /openbsc/src/bsc_api.c
parent94d625bfa09be748aa1a157da8320bd75761d431 (diff)
bsc_api: Allocate the subscriber_connection dynamically
This is a big change to the way we use the subscriber connection. From now on it is is dynamically allocated and we will slowly move from a 1:1 lchan to conn to having more than one lchan per connection. This is the first commit, the subscr_con* methods will move to gsm_data once the use_count is removed from the connection, the freeing of the connection will also change.
Diffstat (limited to 'openbsc/src/bsc_api.c')
-rw-r--r--openbsc/src/bsc_api.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/openbsc/src/bsc_api.c b/openbsc/src/bsc_api.c
index cac08be09..92fe66118 100644
--- a/openbsc/src/bsc_api.c
+++ b/openbsc/src/bsc_api.c
@@ -89,19 +89,23 @@ int bsc_upqueue(struct gsm_network *net)
int gsm0408_rcvmsg(struct msgb *msg, uint8_t link_id)
{
int rc;
- struct gsm_subscriber_connection *conn;
struct bsc_api *api = msg->lchan->ts->trx->bts->network->bsc_api;
+ struct gsm_lchan *lchan;
- conn = &msg->lchan->conn;
- if (conn->allocated) {
- api->dtap(conn, msg);
+ lchan = msg->lchan;
+ if (lchan->conn) {
+ api->dtap(lchan->conn, msg);
} else {
- /* accept the connection or close the lchan */
- rc = api->compl_l3(conn, msg, 0);
- if (rc == BSC_API_CONN_POL_ACCEPT)
- conn->allocated = 1;
- else
- lchan_auto_release(msg->lchan);
+ rc = BSC_API_CONN_POL_REJECT;
+ lchan->conn = subscr_con_allocate(msg->lchan);
+
+ if (lchan->conn)
+ rc = api->compl_l3(lchan->conn, msg, 0);
+
+ if (rc != BSC_API_CONN_POL_ACCEPT) {
+ subscr_con_free(lchan->conn);
+ lchan_auto_release(lchan);
+ }
}
return 0;
@@ -111,6 +115,9 @@ static void send_sapi_reject(struct gsm_subscriber_connection *conn, int link_id
{
struct bsc_api *api;
+ if (!conn)
+ return;
+
api = conn->bts->network->bsc_api;
if (!api || !api->sapi_n_reject)
return;
@@ -129,7 +136,7 @@ static void rll_ind_cb(struct gsm_lchan *lchan, uint8_t link_id, void *_data, en
case BSC_RLLR_IND_REL_IND:
case BSC_RLLR_IND_ERR_IND:
case BSC_RLLR_IND_TIMEOUT:
- send_sapi_reject(&lchan->conn, OBSC_LINKID_CB(msg));
+ send_sapi_reject(lchan->conn, OBSC_LINKID_CB(msg));
msgb_free(msg);
break;
}
@@ -145,7 +152,7 @@ static int bsc_handle_lchan_signal(unsigned int subsys, unsigned int signal,
return 0;
lchan = (struct gsm_lchan *)signal_data;
- if (!lchan)
+ if (!lchan || !lchan->conn)
return 0;
@@ -153,7 +160,7 @@ static int bsc_handle_lchan_signal(unsigned int subsys, unsigned int signal,
if (!bsc || !bsc->clear_request)
return 0;
- bsc->clear_request(&lchan->conn, 0);
+ bsc->clear_request(lchan->conn, 0);
return 0;
}