pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/30218 )

Change subject: tbf: Add tbf_as_{ul,dl}_tbf_const func helpers
......................................................................

tbf: Add tbf_as_{ul,dl}_tbf_const func helpers

This way we can easily get the subclass from the parent if the pointer
is const. Similar to what we already have for the opposite direction
{ul,dl}_tbf_as_tbf_const().

Change-Id: I35e650d13ecf3a5020d136e7d8d99837786503e2
---
M src/tbf_dl.cpp
M src/tbf_dl.h
M src/tbf_ul.cpp
M src/tbf_ul.h
4 files changed, 18 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  fixeria: Looks good to me, approved



diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index e088e65..5006675 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -1272,3 +1272,11 @@
        else
                return NULL;
 }
+
+const struct gprs_rlcmac_dl_tbf *tbf_as_dl_tbf_const(const struct 
gprs_rlcmac_tbf *tbf)
+{
+       if (tbf && tbf->direction == GPRS_RLCMAC_DL_TBF)
+               return static_cast<const gprs_rlcmac_dl_tbf *>(tbf);
+       else
+               return NULL;
+}
diff --git a/src/tbf_dl.h b/src/tbf_dl.h
index bfe9068..3a7c41d 100644
--- a/src/tbf_dl.h
+++ b/src/tbf_dl.h
@@ -130,6 +130,7 @@
                                        int8_t use_trx, bool single_slot);

 struct gprs_rlcmac_dl_tbf *tbf_as_dl_tbf(struct gprs_rlcmac_tbf *tbf);
+const struct gprs_rlcmac_dl_tbf *tbf_as_dl_tbf_const(const struct 
gprs_rlcmac_tbf *tbf);
 /* dispatch Unitdata.DL messages */
 int dl_tbf_handle(struct gprs_rlcmac_bts *bts,
                  const uint32_t tlli, const uint32_t old_tlli,
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 0fe3700..9bfda4f 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -729,6 +729,14 @@
                return NULL;
 }
 
+const struct gprs_rlcmac_ul_tbf *tbf_as_ul_tbf_const(const struct 
gprs_rlcmac_tbf *tbf)
+{
+       if (tbf && tbf->direction == GPRS_RLCMAC_UL_TBF)
+               return static_cast<const gprs_rlcmac_ul_tbf *>(tbf);
+       else
+               return NULL;
+}
+
 void tbf_usf_timeout(struct gprs_rlcmac_ul_tbf *tbf)
 {
        tbf->usf_timeout();
diff --git a/src/tbf_ul.h b/src/tbf_ul.h
index 014b167..c45db44 100644
--- a/src/tbf_ul.h
+++ b/src/tbf_ul.h
@@ -136,6 +136,7 @@
 void update_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, int8_t ta_delta);
 void set_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, uint8_t ta);
 struct gprs_rlcmac_ul_tbf *tbf_as_ul_tbf(struct gprs_rlcmac_tbf *tbf);
+const struct gprs_rlcmac_ul_tbf *tbf_as_ul_tbf_const(const struct 
gprs_rlcmac_tbf *tbf);
 void tbf_usf_timeout(struct gprs_rlcmac_ul_tbf *tbf);
 void ul_tbf_contention_resolution_start(struct gprs_rlcmac_ul_tbf *tbf);
 void ul_tbf_contention_resolution_success(struct gprs_rlcmac_ul_tbf *tbf);

--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/30218
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I35e650d13ecf3a5020d136e7d8d99837786503e2
Gerrit-Change-Number: 30218
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to