From 23ae0e3d23a7bb890964e5840c33d6739b1c665a Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 15 Dec 2022 16:25:27 +0100 Subject: [PATCH] pdch: Introduce APIs to print PDCH name This will allow printing PDCH with same formatting outside of LOGPDCH. Change-Id: If18cb4a48237751e0dddede6793191b36dfe386d --- src/pdch.cpp | 14 ++++++++++++++ src/pdch.h | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/pdch.cpp b/src/pdch.cpp index 5a683ff7..c7d92c10 100644 --- a/src/pdch.cpp +++ b/src/pdch.cpp @@ -1336,3 +1336,17 @@ bool pdch_is_full(const struct gprs_rlcmac_pdch *pdch) pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) == NO_FREE_TFI || find_free_usf(pdch->assigned_usf()) < 0; } + +const char *pdch_name(const struct gprs_rlcmac_pdch *pdch) +{ + static char _pdch_name_buf[128]; + return pdch_name_buf(pdch, _pdch_name_buf, sizeof(_pdch_name_buf)); +} + +char *pdch_name_buf(const struct gprs_rlcmac_pdch *pdch, char *buf, size_t buf_size) +{ + struct osmo_strbuf sb = { .buf = buf, .len = buf_size }; + OSMO_STRBUF_PRINTF(sb, "PDCH(bts=%" PRIu8 ",trx=%" PRIu8 ",ts=%" PRIu8 ")", + pdch->trx->bts->nr, pdch->trx->trx_no, pdch->ts_no); + return buf; +} diff --git a/src/pdch.h b/src/pdch.h index cf4ac4eb..2ca37212 100644 --- a/src/pdch.h +++ b/src/pdch.h @@ -191,11 +191,11 @@ void pdch_free_all_tbf(struct gprs_rlcmac_pdch *pdch); void pdch_disable(struct gprs_rlcmac_pdch *pdch); bool pdch_is_enabled(const struct gprs_rlcmac_pdch *pdch); bool pdch_is_full(const struct gprs_rlcmac_pdch *pdch); +const char *pdch_name(const struct gprs_rlcmac_pdch *pdch); +char *pdch_name_buf(const struct gprs_rlcmac_pdch *pdch, char *buf, size_t buf_size); #ifdef __cplusplus } #endif #define LOGPDCH(pdch, category, level, fmt, args...) \ - LOGP(category, level, "PDCH(bts=%" PRIu8 ",trx=%" PRIu8 ",ts=%" PRIu8 ") " fmt, \ - (pdch)->trx->bts->nr, (pdch)->trx->trx_no, (pdch)->ts_no, \ - ## args) + LOGP(category, level, "%s " fmt, pdch_name(pdch), ## args)