summaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2009-07-23 21:36:44 +0200
committerHarald Welte <laforge@gnumonks.org>2009-07-23 21:39:00 +0200
commitb49248bf48b0856e3b156810681ea3fca44c728a (patch)
treeec284f436f8400673d1ad84554094e86fa8220d2 /openbsc/src
parentc072ad6e299a5930937d336bb13c407c02aefd7b (diff)
move allocating new transaction_ids to transaction.c
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/gsm_04_08.c21
-rw-r--r--openbsc/src/transaction.c14
2 files changed, 16 insertions, 19 deletions
diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c
index 28d573a1d..642d0599b 100644
--- a/openbsc/src/gsm_04_08.c
+++ b/openbsc/src/gsm_04_08.c
@@ -2257,9 +2257,7 @@ static int gsm48_cc_tx_setup(struct gsm_trans *trans, void *arg)
struct msgb *msg = gsm48_msgb_alloc();
struct gsm48_hdr *gh;
struct gsm_mncc *setup = arg;
- struct gsm_trans *transt;
- u_int16_t trans_id_mask = 0;
- int rc, i;
+ int rc, trans_id;
gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh));
@@ -2277,14 +2275,8 @@ static int gsm48_cc_tx_setup(struct gsm_trans *trans, void *arg)
}
/* Get free transaction_id */
- llist_for_each_entry(transt, &trans->subscr->net->trans_list, entry) {
- /* Transaction of our lchan? */
- if (transt->lchan == trans->lchan &&
- transt->transaction_id != 0xff)
- trans_id_mask |= (1 << transt->transaction_id);
- }
- /* Assign free transaction ID */
- if ((trans_id_mask & 0x007f) == 0x7f) {
+ trans_id = trans_assign_trans_id(trans->subscr, GSM48_PDISC_CC, 0);
+ if (trans_id < 0) {
/* no free transaction ID */
rc = mncc_release_ind(trans->subscr->net, trans, trans->callref,
GSM48_CAUSE_LOC_PRN_S_LU,
@@ -2293,12 +2285,7 @@ static int gsm48_cc_tx_setup(struct gsm_trans *trans, void *arg)
trans_free(trans);
return rc;
}
- for (i = 0; i < 7; i++) {
- if ((trans_id_mask & (1 << i)) == 0) {
- trans->transaction_id = i; /* flag = 0 */
- break;
- }
- }
+ trans->transaction_id = trans_id;
gh->msg_type = GSM48_MT_CC_SETUP;
diff --git a/openbsc/src/transaction.c b/openbsc/src/transaction.c
index e917cdd11..f4cef28d2 100644
--- a/openbsc/src/transaction.c
+++ b/openbsc/src/transaction.c
@@ -113,13 +113,18 @@ void trans_free(struct gsm_trans *trans)
talloc_free(trans);
}
-#if 0
+/* allocate an unused transaction ID for the given subscriber
+ * in the given protocol using the ti_flag specified */
int trans_assign_trans_id(struct gsm_subscriber *subscr,
u_int8_t protocol, u_int8_t ti_flag)
{
struct gsm_network *net = subscr->net;
struct gsm_trans *trans;
unsigned int used_tid_bitmask = 0;
+ int i;
+
+ if (ti_flag)
+ ti_flag = 0x8;
/* generate bitmask of already-used TIDs for this (subscr,proto) */
llist_for_each_entry(trans, &net->trans_list, entry) {
@@ -130,5 +135,10 @@ int trans_assign_trans_id(struct gsm_subscriber *subscr,
used_tid_bitmask |= (1 << trans->transaction_id);
}
+ for (i = 0; i <= 7; i++) {
+ if ((used_tid_bitmask & (1 << (i | ti_flag))) == 0)
+ return i | ti_flag;
+ }
+
+ return -1;
}
-#endif