From 9764331062643d5b0771d2a93e6e503f0c029a9a Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 17 Jun 2010 16:41:25 +0800 Subject: bsc_api: Move gsm48_rcvmsg into the BSC API and dispatch. The next step in the way to the BSC API. We have a clear a new connection was opened signal now... and the MSC could use it... --- openbsc/src/bsc_api.c | 22 ++++++++++++++++++++++ openbsc/src/gsm_04_08.c | 6 +++--- openbsc/src/gsm_04_11.c | 4 ++-- openbsc/src/nat/bsc_nat.c | 5 ----- openbsc/src/osmo_msc.c | 16 ++++++++++++++++ 5 files changed, 43 insertions(+), 10 deletions(-) (limited to 'openbsc/src') diff --git a/openbsc/src/bsc_api.c b/openbsc/src/bsc_api.c index 28fc324a3..02fc47309 100644 --- a/openbsc/src/bsc_api.c +++ b/openbsc/src/bsc_api.c @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -84,6 +85,27 @@ int bsc_upqueue(struct gsm_network *net) return work; } +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; + + conn = &msg->lchan->conn; + if (conn->allocated) { + api->dtap(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); + } + + return 0; +} + static void send_sapi_reject(struct gsm_subscriber_connection *conn, int link_id) { struct bsc_api *api; diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c index 9ec2bf916..d9d2f7f33 100644 --- a/openbsc/src/gsm_04_08.c +++ b/openbsc/src/gsm_04_08.c @@ -3096,8 +3096,8 @@ static int gsm0408_rcv_cc(struct msgb *msg) return rc; } -/* here we pass in a msgb from the RSL->RLL. We expect the l3 pointer to be set */ -int gsm0408_rcvmsg(struct msgb *msg, u_int8_t link_id) +/* here we get data from the BSC level... */ +int gsm0408_dispatch(struct gsm_subscriber_connection *conn, struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); u_int8_t pdisc = gh->proto_discr & 0x0f; @@ -3117,7 +3117,7 @@ int gsm0408_rcvmsg(struct msgb *msg, u_int8_t link_id) rc = gsm0408_rcv_rr(msg); break; case GSM48_PDISC_SMS: - rc = gsm0411_rcv_sms(&msg->lchan->conn, msg, link_id); + rc = gsm0411_rcv_sms(conn, msg); break; case GSM48_PDISC_MM_GPRS: case GSM48_PDISC_SM_GPRS: diff --git a/openbsc/src/gsm_04_11.c b/openbsc/src/gsm_04_11.c index a9eee8376..cb7cf8520 100644 --- a/openbsc/src/gsm_04_11.c +++ b/openbsc/src/gsm_04_11.c @@ -913,7 +913,7 @@ static int gsm411_tx_cp_error(struct gsm_trans *trans, u_int8_t cause) /* Entry point for incoming GSM48_PDISC_SMS from abis_rsl.c */ int gsm0411_rcv_sms(struct gsm_subscriber_connection *conn, - struct msgb *msg, u_int8_t link_id) + struct msgb *msg) { struct gsm48_hdr *gh = msgb_l3(msg); u_int8_t msg_type = gh->msg_type; @@ -940,7 +940,7 @@ int gsm0411_rcv_sms(struct gsm_subscriber_connection *conn, trans->sms.cp_state = GSM411_CPS_IDLE; trans->sms.rp_state = GSM411_RPS_IDLE; trans->sms.is_mt = 0; - trans->sms.link_id = link_id; + trans->sms.link_id = UM_SAPI_SMS; trans->conn = conn; use_subscr_con(trans->conn); diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c index 2e8a00dc5..431e6406c 100644 --- a/openbsc/src/nat/bsc_nat.c +++ b/openbsc/src/nat/bsc_nat.c @@ -99,11 +99,6 @@ int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj, void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx) {} -int gsm0408_rcvmsg(struct msgb *msg, u_int8_t link_id) -{ - return -1; -} - static void queue_for_msc(struct bsc_msc_connection *con, struct msgb *msg) { if (write_queue_enqueue(&nat->msc_con->write_queue, msg) != 0) { diff --git a/openbsc/src/osmo_msc.c b/openbsc/src/osmo_msc.c index b647a811f..569634d55 100644 --- a/openbsc/src/osmo_msc.c +++ b/openbsc/src/osmo_msc.c @@ -40,9 +40,25 @@ static void msc_clear_request(struct gsm_subscriber_connection* conn, uint32_t c gsm0408_clear_request(conn, cause); } +static int msc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg, + uint16_t chosen_channel) +{ + gsm0408_dispatch(conn, msg); + + /* TODO: do better */ + return BSC_API_CONN_POL_ACCEPT; +} + +static void msc_dtap(struct gsm_subscriber_connection *conn, struct msgb *msg) +{ + gsm0408_dispatch(conn, msg); +} + static struct bsc_api msc_handler = { .sapi_n_reject = msc_sapi_n_reject, .clear_request = msc_clear_request, + .compl_l3 = msc_compl_l3, + .dtap = msc_dtap, }; struct bsc_api *msc_bsc_api() { -- cgit v1.2.3