diff options
author | Max <msuraev@sysmocom.de> | 2018-01-02 14:17:04 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2018-01-12 14:17:52 +0000 |
commit | 8dce1de6d2669023b715945cc58813380ac7f322 (patch) | |
tree | ad32dcb8b1b16689fc09b4990541372a749f9b3f /src/tbf.h | |
parent | 5081806f4d41ceccf5b5421c9644113ac41e2524 (diff) |
TBF: cleanup state flag handling
* introduce generic function to check whether particular flag was set
for'a TBF and clear it if necessary. Use this instead of
clear_poll_timeout_flag()
* add function to explicitly set assignment and appropriate state flags
Overall this makes the code easier to read and debug.
Related: OS#1759
Change-Id: Ic4560280c72f91700f2e19c6c7f6658dc29625c2
Diffstat (limited to 'src/tbf.h')
-rw-r--r-- | src/tbf.h | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -180,6 +180,8 @@ struct gprs_rlcmac_tbf { bool state_is(enum gprs_rlcmac_tbf_state rhs) const; bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const; void set_state(enum gprs_rlcmac_tbf_state new_state); + bool check_n_clear(uint8_t state_flag); + void set_assigned_on(uint8_t state_flag, bool check_ccch); const char *state_name() const; const char *name() const; @@ -368,6 +370,17 @@ inline const char *gprs_rlcmac_tbf::state_name() const return tbf_state_name[state]; } +/* Set assignment state and corrsponding flags */ +inline void gprs_rlcmac_tbf::set_assigned_on(uint8_t state_flag, bool check_ccch) +{ + set_state(GPRS_RLCMAC_ASSIGN); + if (check_ccch) { + if (!(state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))) + state_flags |= (1 << state_flag); + } else + state_flags |= (1 << state_flag); +} + inline void gprs_rlcmac_tbf::set_state(enum gprs_rlcmac_tbf_state new_state) { LOGP(DRLCMAC, LOGL_DEBUG, "%s changes state from %s to %s\n", @@ -376,6 +389,16 @@ inline void gprs_rlcmac_tbf::set_state(enum gprs_rlcmac_tbf_state new_state) state = new_state; } +inline bool gprs_rlcmac_tbf::check_n_clear(uint8_t state_flag) +{ + if ((state_flags & (1 << state_flag))) { + state_flags &= ~(1 << state_flag); + return true; + } + + return false; +} + inline LListHead<gprs_rlcmac_tbf>& gprs_rlcmac_tbf::list() { return this->m_list; @@ -451,7 +474,7 @@ struct gprs_rlcmac_dl_tbf : public gprs_rlcmac_tbf { int rcvd_dl_ack(bool final_ack, unsigned first_bsn, struct bitvec *rbb); struct msgb *create_dl_acked_block(uint32_t fn, uint8_t ts); void trigger_ass(struct gprs_rlcmac_tbf *old_tbf); - void clear_poll_timeout_flag(); + bool handle_ack_nack(); void request_dl_ack(); bool need_control_ts() const; |