aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bts.cpp4
-rw-r--r--src/tbf.h51
-rw-r--r--src/tbf_dl.cpp8
3 files changed, 54 insertions, 9 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index 72e1621..3d29ad6 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -759,7 +759,7 @@ int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, bool is_11bit,
} else {
tbf->set_ta(ta);
TBF_SET_STATE(tbf, GPRS_RLCMAC_FLOW);
- tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_CCCH);
+ TBF_ASS_TYPE_SET(tbf, GPRS_RLCMAC_FLAG_CCCH);
T_START(tbf, T3169, m_bts.t3169, 0, "RACH (new UL-TBF)", true);
LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] START\n");
LOGPTBF(tbf, LOGL_DEBUG, "RX: [PCU <- BTS] RACH "
@@ -1042,7 +1042,7 @@ void gprs_rlcmac_pdch::rcv_control_ack(Packet_Control_Acknowledgement_t *packet,
LOGPTBF(new_tbf, LOGL_INFO,
"The TBF has been confirmed on the PACCH, "
"changed type from CCCH to PACCH\n");
- new_tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
+ TBF_ASS_TYPE_SET(new_tbf, GPRS_RLCMAC_FLAG_PACCH);
}
TBF_SET_STATE(new_tbf, GPRS_RLCMAC_FLOW);
/* stop pending assignment timer */
diff --git a/src/tbf.h b/src/tbf.h
index 803ea33..2ed63f9 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -191,6 +191,8 @@ enum tbf_timers {
#define TBF_POLL_SCHED_SET(t) do { t->poll_sched_set(__FILE__, __LINE__); } while(0)
#define TBF_POLL_SCHED_UNSET(t) do { t->poll_sched_unset(__FILE__, __LINE__); } while(0)
#define TBF_SET_ASS_ON(t, fl, chk) do { t->set_assigned_on(fl, chk, __FILE__, __LINE__); } while(0)
+#define TBF_ASS_TYPE_SET(t, kind) do { t->ass_type_mod(kind, false, __FILE__, __LINE__); } while(0)
+#define TBF_ASS_TYPE_UNSET(t, kind) do { t->ass_type_mod(kind, true, __FILE__, __LINE__); } while(0)
struct gprs_rlcmac_tbf {
gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir);
@@ -213,6 +215,7 @@ struct gprs_rlcmac_tbf {
void check_pending_ass();
bool check_n_clear(uint8_t state_flag);
void set_assigned_on(uint8_t state_flag, bool check_ccch, const char *file, int line);
+ void ass_type_mod(uint8_t t, bool unset, const char *file, int line);
const char *state_name() const;
const char *name() const;
@@ -422,11 +425,57 @@ inline void gprs_rlcmac_tbf::set_assigned_on(uint8_t state_flag, bool check_ccch
set_state(GPRS_RLCMAC_ASSIGN, file, line);
if (check_ccch) {
if (!(state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH)))
- state_flags |= (1 << state_flag);
+ ass_type_mod(state_flag, false, file, line);
} else
state_flags |= (1 << state_flag);
}
+inline void gprs_rlcmac_tbf::ass_type_mod(uint8_t t, bool unset, const char *file, int line)
+{
+ const char *ch = "UNKNOWN";
+ switch (t) {
+ case GPRS_RLCMAC_FLAG_CCCH:
+ if (unset) {
+ if (!(state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH)))
+ return;
+ } else {
+ if (state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))
+ LOGPSRC(DTBF, LOGL_ERROR, file, line,
+ "%s attempted to set ass. type CCCH which is already set.\n",
+ tbf_name(this));
+ }
+ ch = "CCCH";
+ break;
+ case GPRS_RLCMAC_FLAG_PACCH:
+ if (unset) {
+ if (!(state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH)))
+ return;
+ } else {
+ if (state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH))
+ LOGPSRC(DTBF, LOGL_ERROR, file, line,
+ "%s attempted to set ass. type PACCH which is already set.\n",
+ tbf_name(this));
+ }
+ ch = "PACCH";
+ break;
+ default:
+ LOGPSRC(DTBF, LOGL_ERROR, file, line, "%s attempted to %sset unexpected ass. type %d - FIXME!\n",
+ tbf_name(this), unset ? "un" : "", t);
+ return;
+ }
+
+ LOGPSRC(DTBF, LOGL_INFO, file, line, "%s %sset ass. type %s [prev CCCH:%u, PACCH:%u]\n",
+ tbf_name(this), unset ? "un" : "", ch,
+ state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH),
+ state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH));
+
+ if (unset) {
+ state_flags &= GPRS_RLCMAC_FLAG_TO_MASK; /* keep to flags */
+ state_flags &= ~(1 << t);
+ } else
+ state_flags |= (1 << t);
+}
+
inline void gprs_rlcmac_tbf::set_state(enum gprs_rlcmac_tbf_state new_state, const char *file, int line)
{
LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes state from %s to %s\n",
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 0587a4a..dc4fa6a 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -1104,9 +1104,7 @@ int gprs_rlcmac_dl_tbf::release()
m_wait_confirm = 0;
m_window.reset();
- /* keep to flags */
- state_flags &= GPRS_RLCMAC_FLAG_TO_MASK;
- state_flags &= ~(1 << GPRS_RLCMAC_FLAG_CCCH);
+ TBF_ASS_TYPE_UNSET(this, GPRS_RLCMAC_FLAG_CCCH);
return 0;
}
@@ -1132,9 +1130,7 @@ int gprs_rlcmac_dl_tbf::abort()
/* reset rlc states */
m_window.reset();
- /* keep to flags */
- state_flags &= GPRS_RLCMAC_FLAG_TO_MASK;
- state_flags &= ~(1 << GPRS_RLCMAC_FLAG_CCCH);
+ TBF_ASS_TYPE_UNSET(this, GPRS_RLCMAC_FLAG_CCCH);
return 0;
}