diff --git a/src/gprs_ms.cpp b/src/gprs_ms.cpp index f62facf5..318ebec2 100644 --- a/src/gprs_ms.cpp +++ b/src/gprs_ms.cpp @@ -538,6 +538,32 @@ int GprsMs::first_common_ts() const return -1; } +uint8_t GprsMs::dl_slots() const +{ + uint8_t slots = 0; + + if (m_dl_tbf) + slots |= m_dl_tbf->dl_slots(); + + if (m_ul_tbf) + slots |= m_ul_tbf->dl_slots(); + + return slots; +} + +uint8_t GprsMs::ul_slots() const +{ + uint8_t slots = 0; + + if (m_dl_tbf) + slots |= m_dl_tbf->ul_slots(); + + if (m_ul_tbf) + slots |= m_ul_tbf->ul_slots(); + + return slots; +} + void GprsMs::set_reserved_slots(gprs_rlcmac_trx *trx, uint8_t ul_slots, uint8_t dl_slots) { diff --git a/src/gprs_ms.h b/src/gprs_ms.h index 910ccb83..840a2295 100644 --- a/src/gprs_ms.h +++ b/src/gprs_ms.h @@ -80,6 +80,8 @@ public: uint8_t current_cs_dl() const; int first_common_ts() const; + uint8_t dl_slots() const; + uint8_t ul_slots() const; uint8_t reserved_dl_slots() const; uint8_t reserved_ul_slots() const; gprs_rlcmac_trx *current_trx() const; diff --git a/src/tbf.cpp b/src/tbf.cpp index e83873ab..006f66e0 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -935,6 +935,42 @@ uint8_t gprs_rlcmac_tbf::tsc() const return trx->pdch[first_ts].tsc; } +uint8_t gprs_rlcmac_tbf::dl_slots() const +{ + uint8_t slots = 0; + size_t i; + + if (direction == GPRS_RLCMAC_UL_TBF) + return 0; + + for (i = 0; i < ARRAY_SIZE(pdch); i += 1) + if (pdch[i]) + slots |= 1 << i; + + return slots; +} + +uint8_t gprs_rlcmac_tbf::ul_slots() const +{ + uint8_t slots = 0; + size_t i; + + if (direction == GPRS_RLCMAC_DL_TBF) { + if (control_ts < 8) + slots |= 1 << control_ts; + if (first_common_ts < 8) + slots |= 1 << first_common_ts; + + return slots; + } + + for (i = 0; i < ARRAY_SIZE(pdch); i += 1) + if (pdch[i]) + slots |= 1 << i; + + return slots; +} + void tbf_print_vty_info(struct vty *vty, struct llist_head *ltbf) { gprs_rlcmac_tbf *tbf = llist_pods_entry(ltbf, gprs_rlcmac_tbf); diff --git a/src/tbf.h b/src/tbf.h index 82ade4e8..f6f13f75 100644 --- a/src/tbf.h +++ b/src/tbf.h @@ -158,6 +158,8 @@ struct gprs_rlcmac_tbf { const gprs_llc_queue *llc_queue() const; time_t created_ts() const; + uint8_t dl_slots() const; + uint8_t ul_slots() const; /* attempt to make things a bit more fair */ void rotate_in_list();