transaction: drop meaningless ti_flag of trans_assign_trans_id()

According to GSM 04.07, the TI flag takes one bit and can be
either of the following:

  '0'B - transaction is allocated by sender of a message,
  '1'B - transaction is allocated by receiver of a message.

Since we store transaction ID in gsm_trans structure, we also store
TI flag (as a part of transaction ID), which in this context means:

  '0'B - transaction is allocated by us (OsmoMSC),
  '1'B - transaction is allocated by some MS.

In 100% cases, trans_assign_trans_id() is used to assign transaction IDs
to transactions allocated by us (i.e. OsmoMSC) for MT connections. And
there is no need to use it for MO transactions, because they basically
already do contain a valid transaction ID assigned by the MS.

Change-Id: Ie11999900b1789652ee078d34636dcda1e137eb0
diff --git a/include/osmocom/msc/transaction.h b/include/osmocom/msc/transaction.h
index 36e9bc1..c5c740c 100644
--- a/include/osmocom/msc/transaction.h
+++ b/include/osmocom/msc/transaction.h
@@ -111,7 +111,7 @@
 void trans_free(struct gsm_trans *trans);
 
 int trans_assign_trans_id(const struct gsm_network *net, const struct vlr_subscr *vsub,
-			  uint8_t protocol, uint8_t ti_flag);
+			  uint8_t protocol);
 struct gsm_trans *trans_has_conn(const struct ran_conn *conn);
 void trans_conn_closed(const struct ran_conn *conn);
 
diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c
index 93e136c..b84fd03 100644
--- a/src/libmsc/gsm_04_08_cc.c
+++ b/src/libmsc/gsm_04_08_cc.c
@@ -630,8 +630,7 @@
 	}
 
 	/* Get free transaction_id */
-	trans_id = trans_assign_trans_id(trans->net, trans->vsub,
-					 GSM48_PDISC_CC, 0);
+	trans_id = trans_assign_trans_id(trans->net, trans->vsub, GSM48_PDISC_CC);
 	if (trans_id < 0) {
 		/* no free transaction ID */
 		rc = mncc_release_ind(trans->net, trans, trans->callref,
diff --git a/src/libmsc/gsm_04_11.c b/src/libmsc/gsm_04_11.c
index e63d1b6..ccb2610 100644
--- a/src/libmsc/gsm_04_11.c
+++ b/src/libmsc/gsm_04_11.c
@@ -1064,7 +1064,7 @@
 	LOGP(DLSMS, LOGL_INFO, "Going to send a MT SMS\n");
 
 	/* Generate a new transaction ID */
-	tid = trans_assign_trans_id(net, vsub, GSM48_PDISC_SMS, 0);
+	tid = trans_assign_trans_id(net, vsub, GSM48_PDISC_SMS);
 	if (tid == -1) {
 		LOGP(DLSMS, LOGL_ERROR, "No available transaction IDs\n");
 		return NULL;
diff --git a/src/libmsc/gsm_09_11.c b/src/libmsc/gsm_09_11.c
index dca315d..08721d4 100644
--- a/src/libmsc/gsm_09_11.c
+++ b/src/libmsc/gsm_09_11.c
@@ -306,8 +306,7 @@
 	osmo_counter_inc(net->active_nc_ss);
 
 	/* Assign transaction ID */
-	tid = trans_assign_trans_id(trans->net,
-		trans->vsub, GSM48_PDISC_NC_SS, 0);
+	tid = trans_assign_trans_id(trans->net, trans->vsub, GSM48_PDISC_NC_SS);
 	if (tid < 0) {
 		LOGP(DMM, LOGL_ERROR, "No free transaction ID\n");
 		/* TODO: inform HLR about this */
diff --git a/src/libmsc/transaction.c b/src/libmsc/transaction.c
index 7c91c92..237191d 100644
--- a/src/libmsc/transaction.c
+++ b/src/libmsc/transaction.c
@@ -179,22 +179,19 @@
 }
 
 /*! allocate an unused transaction ID for the given subscriber
- * in the given protocol using the ti_flag specified
+ * in the given protocol using TI flag = 0 (allocated by us).
+ * See GSM 04.07, section 11.2.3.1.3 "Transaction identifier".
  * \param[in] net GSM network
  * \param[in] subscr Subscriber for which to find ID
  * \param[in] protocol Protocol for whihc to find ID
- * \param[in] ti_flag FIXME
  */
 int trans_assign_trans_id(const struct gsm_network *net, const struct vlr_subscr *vsub,
-			  uint8_t protocol, uint8_t ti_flag)
+			  uint8_t protocol)
 {
 	struct gsm_trans *trans;
 	unsigned int used_tid_bitmask = 0;
 	int i, j, h;
 
-	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) {
 		if (trans->vsub != vsub ||
@@ -206,10 +203,10 @@
 
 	/* find a new one, trying to go in a 'circular' pattern */
 	for (h = 6; h > 0; h--)
-		if (used_tid_bitmask & (1 << (h | ti_flag)))
+		if (used_tid_bitmask & (1 << h))
 			break;
 	for (i = 0; i < 7; i++) {
-		j = ((h + i) % 7) | ti_flag;
+		j = (h + i) % 7;
 		if ((used_tid_bitmask & (1 << j)) == 0)
 			return j;
 	}