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.
This commit is contained in:
Holger Hans Peter Freyther 2013-10-27 20:57:35 +01:00
parent 34f6e5ebe6
commit 5464c9baf2
4 changed files with 23 additions and 15 deletions

View File

@ -481,7 +481,7 @@ void BTS::trigger_dl_ass(
/* 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;

View File

@ -154,7 +154,7 @@ int gprs_rlcmac_lost_rep(struct gprs_rlcmac_tbf *tbf)
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 @@ int gprs_rlcmac_dl_bw(struct gprs_rlcmac_tbf *tbf, uint16_t octets)
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 */

View File

@ -72,10 +72,10 @@ static inline void tbf_update_ms_class(struct gprs_rlcmac_tbf *tbf,
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 @@ static int tbf_new_dl_assignment(struct gprs_rlcmac_bts *bts,
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 tbf_handle(struct gprs_rlcmac_bts *bts,
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 @@ void gprs_rlcmac_tbf::poll_timeout()
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

View File

@ -122,6 +122,9 @@ struct gprs_rlcmac_tbf {
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 @@ struct gprs_rlcmac_tbf {
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 @@ struct gprs_rlcmac_tbf {
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 @@ struct gprs_rlcmac_tbf {
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 @@ inline uint8_t gprs_rlcmac_tbf::tfi() const
return m_tfi;
}
inline const char *gprs_rlcmac_tbf::imsi() const
{
return m_imsi;
}
const char *tbf_name(gprs_rlcmac_tbf *tbf);