aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Whyte <keith@rhizomatica.org>2022-10-15 01:08:53 +0100
committerKeith Whyte <keith@rhizomatica.org>2022-10-15 01:55:55 +0100
commit678c4988d5a760ad44131a61ac5f8e97e26d5dc0 (patch)
treea4a1ad4a44e6d006c2fd015269e12886b0ab2c6c
parentff37f1c09281ba221f76c75777abf3b0cd803b01 (diff)
LCLS: Add function trans_find_by_same_gcr()
-rw-r--r--include/osmocom/msc/transaction.h2
-rw-r--r--src/libmsc/transaction.c23
2 files changed, 25 insertions, 0 deletions
diff --git a/include/osmocom/msc/transaction.h b/include/osmocom/msc/transaction.h
index e422c111c..1bbb05f5b 100644
--- a/include/osmocom/msc/transaction.h
+++ b/include/osmocom/msc/transaction.h
@@ -152,6 +152,8 @@ struct gsm_trans *trans_find_by_callref(const struct gsm_network *net,
struct gsm_trans *trans_find_by_sm_rp_mr(const struct gsm_network *net,
const struct vlr_subscr *vsub,
uint8_t sm_rp_mr);
+struct gsm_trans *trans_find_by_same_gcr(const struct gsm_network *net,
+ const struct gsm_trans *trans);
struct osmo_lcls *trans_lcls_compose(const struct gsm_trans *trans, bool use_lac);
diff --git a/src/libmsc/transaction.c b/src/libmsc/transaction.c
index 53236f494..e5cade692 100644
--- a/src/libmsc/transaction.c
+++ b/src/libmsc/transaction.c
@@ -110,6 +110,29 @@ struct gsm_trans *trans_find_by_sm_rp_mr(const struct gsm_network *net,
return NULL;
}
+/*! Find a transaction by global call reference
+ * \param[in] net Network in which we should search
+ * \param[in] trans Transaction containing GCR to search for
+ * \returns Matching transaction, if any
+ */
+struct gsm_trans *trans_find_by_same_gcr(const struct gsm_network *net,
+ const struct gsm_trans *trans)
+{
+ struct gsm_trans *trans_other;
+
+ llist_for_each_entry(trans_other, &net->trans_list, entry) {
+ /* don't report back the same transaction */
+ if (trans_other == trans)
+ continue;
+ /* don't consider any trans where GCR is not available */
+ if (trans_other->cc.lcls == NULL || trans_other->cc.lcls->gcr_available == false)
+ continue;
+ if (!memcmp(&trans_other->cc.lcls->gcr, &trans->cc.lcls->gcr, sizeof(trans->cc.lcls->gcr)))
+ return trans_other;
+ }
+ return NULL;
+}
+
struct osmo_lcls *trans_lcls_compose(const struct gsm_trans *trans, bool use_lac)
{
if (!trans) {