tbf: Have one imsi field and assign it through a function

Have one IMSI field per TBF and assign through a function call.
The IMSI should be used to look-up the TBF on the SGSN->PCU
direction.
diff --git a/src/bts.cpp b/src/bts.cpp
index 285c184..91436f7 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -481,7 +481,7 @@
 		/* change state */
 		tbf_new_state(tbf, GPRS_RLCMAC_ASSIGN);
 		tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_CCCH);
-		strncpy(tbf->dir.dl.imsi, imsi, sizeof(tbf->dir.dl.imsi));
+		tbf->assign_imsi(imsi);
 		/* send immediate assignment */
 		tbf->bts->snd_dl_ass(tbf, 0, imsi);
 		tbf->dir.dl.wait_confirm = 1;
diff --git a/src/gprs_rlcmac_meas.cpp b/src/gprs_rlcmac_meas.cpp
index 5bb74cd..dd9de5a 100644
--- a/src/gprs_rlcmac_meas.cpp
+++ b/src/gprs_rlcmac_meas.cpp
@@ -154,7 +154,7 @@
 		return -EINVAL;
 
 	LOGP(DRLCMACMEAS, LOGL_INFO, "DL packet loss of IMSI=%s / TLLI=0x%08x: "
-		"%d%%\n", tbf->meas.imsi, tbf->tlli(),
+		"%d%%\n", tbf->imsi(), tbf->tlli(),
 		tbf->meas.dl_loss_lost * 100 / sum);
 
 	return 0;
@@ -179,7 +179,7 @@
 		return 0;
 
 	LOGP(DRLCMACMEAS, LOGL_INFO, "DL Bandwitdh of IMSI=%s / TLLI=0x%08x: "
-		"%d KBits/s\n", tbf->meas.imsi, tbf->tlli(),
+		"%d KBits/s\n", tbf->imsi(), tbf->tlli(),
 		tbf->meas.dl_bw_octets / elapsed);
 
 	/* reset bandwidth values timestamp */
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 0e2481b..fac5aaf 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -72,10 +72,10 @@
 		tbf->ms_class = ms_class;
 }
 
-static inline void tbf_assign_imsi(struct gprs_rlcmac_tbf *tbf,
-					const char *imsi)
+void gprs_rlcmac_tbf::assign_imsi(const char *imsi)
 {
-	strncpy(tbf->meas.imsi, imsi, sizeof(tbf->meas.imsi) - 1);
+	strncpy(m_imsi, imsi, sizeof(m_imsi));
+	m_imsi[sizeof(m_imsi) - 1] = '\0';
 }
 
 static struct gprs_rlcmac_tbf *tbf_lookup_dl(BTS *bts,
@@ -205,14 +205,14 @@
 	memcpy(tbf->llc_frame, data, len);
 	tbf->llc_length = len;
 
+	/* Store IMSI for later look-up and PCH retransmission */
+	tbf->assign_imsi(imsi);
+
 	/* trigger downlink assignment and set state to ASSIGN.
 	 * we don't use old_downlink, so the possible uplink is used
 	 * to trigger downlink assignment. if there is no uplink,
 	 * AGCH is used. */
 	tbf->bts->trigger_dl_ass(tbf, old_tbf, imsi);
-
-	/* store IMSI for debugging purpose. TODO: it is more than debugging */
-	tbf_assign_imsi(tbf, imsi);
 	return 0;
 }
 
@@ -232,7 +232,7 @@
 		int rc = tbf_append_data(tbf, bts, ms_class,
 						delay_csec, data, len);
 		if (rc >= 0)
-			tbf_assign_imsi(tbf, imsi);
+			tbf->assign_imsi(imsi);
 		return rc;
 	} 
 
@@ -526,9 +526,9 @@
 			LOGP(DRLCMAC, LOGL_DEBUG, "Re-send dowlink assignment "
 				"for %s on PCH (IMSI=%s)\n",
 				tbf_name(this),
-				dir.dl.imsi);
+				m_imsi);
 			/* send immediate assignment */
-			bts->snd_dl_ass(this, 0, dir.dl.imsi);
+			bts->snd_dl_ass(this, 0, m_imsi);
 			dir.dl.wait_confirm = 1;
 		}
 	} else
diff --git a/src/tbf.h b/src/tbf.h
index e8b66c9..e31653d 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -122,6 +122,9 @@
 
 	uint8_t tfi() const;
 
+	const char *imsi() const;
+	void assign_imsi(const char *imsi);
+
 	struct llist_head list;
 	uint32_t state_flags;
 	enum gprs_rlcmac_tbf_direction direction;
@@ -161,7 +164,6 @@
 			uint16_t v_a;	/* ack state */
 			char v_b[RLC_MAX_SNS/2]; /* acknowledge state array */
 			int32_t tx_counter; /* count all transmitted blocks */
-			char imsi[16]; /* store IMSI for PCH retransmission */
 			uint8_t wait_confirm; /* wait for CCCH IMM.ASS cnf */
 		} dl;
 		struct {
@@ -190,8 +192,6 @@
 	unsigned int num_fT_exp; /* number of consecutive fT expirations */
 
 	struct {
-		char imsi[16];
-
 		struct timeval dl_bw_tv; /* timestamp for dl bw calculation */
 		uint32_t dl_bw_octets; /* number of octets since bw_tv */
 
@@ -227,6 +227,9 @@
 	uint8_t m_tlli_valid;
 	uint8_t m_tfi;
 
+	/* store IMSI for look-up and PCH retransmission */
+	char m_imsi[16];
+
 protected:
 	gprs_rlcmac_bts *bts_data() const;
 
@@ -287,4 +290,9 @@
 	return m_tfi;
 }
 
+inline const char *gprs_rlcmac_tbf::imsi() const
+{
+	return m_imsi;
+}
+
 const char *tbf_name(gprs_rlcmac_tbf *tbf);