diff options
author | Harald Welte <laforge@gnumonks.org> | 2009-07-23 21:36:44 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2009-07-23 21:36:44 +0200 |
commit | 78283ef151aa4cac6eaf9728b3df65a117108186 (patch) | |
tree | af4480ce858125f787f92684ab77a512746e2161 /openbsc/src/transaction.c | |
parent | 9ee4825bbf71d2fdcf87e484a716a3d96787baba (diff) |
move allocating new transaction_ids to transaction.c
Diffstat (limited to 'openbsc/src/transaction.c')
-rw-r--r-- | openbsc/src/transaction.c | 14 |
1 files changed, 12 insertions, 2 deletions
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 |