pespin submitted this change.

View Change

Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved
pdch: Introduce APIs to print PDCH name

This will allow printing PDCH with same formatting outside of LOGPDCH.

Change-Id: If18cb4a48237751e0dddede6793191b36dfe386d
---
M src/pdch.cpp
M src/pdch.h
2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/pdch.cpp b/src/pdch.cpp
index 5a683ff..c7d92c1 100644
--- a/src/pdch.cpp
+++ b/src/pdch.cpp
@@ -1336,3 +1336,17 @@
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 cf4ac4e..2ca3721 100644
--- a/src/pdch.h
+++ b/src/pdch.h
@@ -191,11 +191,11 @@
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)

To view, visit change 30619. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: If18cb4a48237751e0dddede6793191b36dfe386d
Gerrit-Change-Number: 30619
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged