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.
diff --git a/openbsc/src/bsc_api.c b/openbsc/src/bsc_api.c
index c86d62c..085a8c9 100644
--- a/openbsc/src/bsc_api.c
+++ b/openbsc/src/bsc_api.c
@@ -174,12 +174,18 @@
}
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;