From 8d380dcaddcdd2d1379911388351673f4596f79a Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 10 Nov 2010 10:16:02 +0100 Subject: [PATCH] bsc_api: Change submit dtap to allow to automatically use the SACH For SAPI=3 on a TCH it might be nice to use the SACH to submit the message. The api allows to automatically use the SACH if a message like this is submitted. --- openbsc/include/openbsc/bsc_api.h | 2 +- openbsc/src/bsc_api.c | 8 +++++++- openbsc/src/gsm_04_08.c | 2 +- openbsc/src/gsm_04_11.c | 2 +- openbsc/src/gsm_04_80.c | 8 ++++---- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/openbsc/include/openbsc/bsc_api.h b/openbsc/include/openbsc/bsc_api.h index 314ce9c3b..36ec3705c 100644 --- a/openbsc/include/openbsc/bsc_api.h +++ b/openbsc/include/openbsc/bsc_api.h @@ -26,7 +26,7 @@ struct bsc_api { }; int bsc_api_init(struct gsm_network *network, struct bsc_api *api); -int gsm0808_submit_dtap(struct gsm_subscriber_connection *conn, struct msgb *msg, int link_id); +int gsm0808_submit_dtap(struct gsm_subscriber_connection *conn, struct msgb *msg, int link_id, int allow_sach); int gsm0808_assign_req(struct gsm_subscriber_connection *conn, int chan_mode, int full_rate); int gsm0808_cipher_mode(struct gsm_subscriber_connection *conn, int cipher, const uint8_t *key, int len, int include_imeisv); diff --git a/openbsc/src/bsc_api.c b/openbsc/src/bsc_api.c index c86d62cc3..085a8c9da 100644 --- a/openbsc/src/bsc_api.c +++ b/openbsc/src/bsc_api.c @@ -174,12 +174,18 @@ int bsc_api_init(struct gsm_network *network, struct bsc_api *api) } int gsm0808_submit_dtap(struct gsm_subscriber_connection *conn, - struct msgb *msg, int link_id) + struct msgb *msg, int link_id, int allow_sach) { uint8_t sapi = link_id & 0x7; msg->lchan = conn->lchan; msg->trx = msg->lchan->ts->trx; + /* If we are on a TCH and need to submit a SMS (on SAPI=3) we need to use the SACH */ + if (allow_sach && sapi != 0) { + if (conn->lchan->type == GSM_LCHAN_TCH_F || conn->lchan->type == GSM_LCHAN_TCH_H) + link_id |= 0x40; + } + msg->l3h = msg->data; if (conn->lchan->sapis[sapi] == LCHAN_SAPI_UNUSED) { OBSC_LINKID_CB(msg) = link_id; diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c index fd3c002a6..5a76baa9c 100644 --- a/openbsc/src/gsm_04_08.c +++ b/openbsc/src/gsm_04_08.c @@ -104,7 +104,7 @@ static int gsm48_conn_sendmsg(struct msgb *msg, struct gsm_subscriber_connection gh->proto_discr, gh->msg_type); } - return gsm0808_submit_dtap(conn, msg, 0); + return gsm0808_submit_dtap(conn, msg, 0, 0); } int gsm48_cc_tx_notify_ss(struct gsm_trans *trans, const char *message) diff --git a/openbsc/src/gsm_04_11.c b/openbsc/src/gsm_04_11.c index 2931026bb..c46f7728e 100644 --- a/openbsc/src/gsm_04_11.c +++ b/openbsc/src/gsm_04_11.c @@ -142,7 +142,7 @@ static int gsm411_sendmsg(struct gsm_subscriber_connection *conn, struct msgb *m { DEBUGP(DSMS, "GSM4.11 TX %s\n", hexdump(msg->data, msg->len)); msg->l3h = msg->data; - return gsm0808_submit_dtap(conn, msg, link_id); + return gsm0808_submit_dtap(conn, msg, link_id, 1); } /* SMC TC1* is expired */ diff --git a/openbsc/src/gsm_04_80.c b/openbsc/src/gsm_04_80.c index e0f47ff01..8414dc9fe 100644 --- a/openbsc/src/gsm_04_80.c +++ b/openbsc/src/gsm_04_80.c @@ -107,7 +107,7 @@ int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn, | (1<<7); /* TI direction = 1 */ gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE; - return gsm0808_submit_dtap(conn, msg, 0); + return gsm0808_submit_dtap(conn, msg, 0, 0); } int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn, @@ -136,7 +136,7 @@ int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn, gh->proto_discr |= req->transaction_id | (1<<7); /* TI direction = 1 */ gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE; - return gsm0808_submit_dtap(conn, msg, 0); + return gsm0808_submit_dtap(conn, msg, 0, 0); } int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text) @@ -156,7 +156,7 @@ int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, c gh->proto_discr = GSM48_PDISC_NC_SS; gh->msg_type = GSM0480_MTYPE_REGISTER; - return gsm0808_submit_dtap(conn, msg, 0); + return gsm0808_submit_dtap(conn, msg, 0, 0); } int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn) @@ -172,5 +172,5 @@ int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn) gh->proto_discr = GSM48_PDISC_NC_SS; gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE; - return gsm0808_submit_dtap(conn, msg, 0); + return gsm0808_submit_dtap(conn, msg, 0, 0); }