From f44fefe0ff3452f43a627e33e127d34a490d0d6d Mon Sep 17 00:00:00 2001 From: Ivan Kluchnikov Date: Wed, 23 Aug 2017 17:53:37 +0300 Subject: transaction: Add new function trans_find_by_lchan Function returns transaction for given lchan. In case of active call hold procedure it could be two transactions in a list with links to the same lchan: * transaction for call on hold * transaction for active call. In this case function ignores transaction which was put on hold and returns active call transaction. Change-Id: I41171d4e61abfa5f2b01d6fbf4a0ac98073d97a9 --- openbsc/include/openbsc/transaction.h | 1 + openbsc/src/libmsc/transaction.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/openbsc/include/openbsc/transaction.h b/openbsc/include/openbsc/transaction.h index 9a87d04e4..624db7418 100644 --- a/openbsc/include/openbsc/transaction.h +++ b/openbsc/include/openbsc/transaction.h @@ -65,6 +65,7 @@ struct gsm_trans *trans_find_by_id(struct gsm_subscriber_connection *conn, uint8_t proto, uint8_t trans_id); struct gsm_trans *trans_find_by_callref(struct gsm_network *net, uint32_t callref); +struct gsm_trans *trans_find_by_lchan(struct gsm_lchan *lchan); struct gsm_trans *trans_alloc(struct gsm_network *net, struct gsm_subscriber *subscr, diff --git a/openbsc/src/libmsc/transaction.c b/openbsc/src/libmsc/transaction.c index dba4bed17..ac0405f02 100644 --- a/openbsc/src/libmsc/transaction.c +++ b/openbsc/src/libmsc/transaction.c @@ -61,6 +61,32 @@ struct gsm_trans *trans_find_by_callref(struct gsm_network *net, return NULL; } +struct gsm_trans *trans_find_by_lchan(struct gsm_lchan *lchan) +{ + struct gsm_trans *temp; + struct gsm_trans *trans = NULL; + struct gsm_network *net = lchan->ts->trx->bts->network; + + llist_for_each_entry(temp, &net->trans_list, entry) { + if (!temp->conn) + continue; + if (temp->conn->lchan != lchan && temp->conn->ho_lchan != lchan) + continue; + if (!trans) { + trans = temp; + if (trans->tch_recv) + break; + else + continue; + } + if (temp->tch_recv) { + trans = temp; + break; + } + } + return trans; +} + struct gsm_trans *trans_alloc(struct gsm_network *net, struct gsm_subscriber *subscr, uint8_t protocol, uint8_t trans_id, -- cgit v1.2.3