[PATCH] libosmocore[master]: abis_nm: Introduce abis_nm_dump_foh()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Mar 17 09:35:18 UTC 2018


Review at  https://gerrit.osmocom.org/7334

abis_nm: Introduce abis_nm_dump_foh()

This is a more modern way of printing the Abis OML Formatted Object
Header, without assuming that it would be used in a log statement
or prescribing the log level to be used.

Change-Id: I9b2c2afec28882b817d104d5b062651ade7aadd8
---
M include/osmocom/gsm/abis_nm.h
M src/gsm/abis_nm.c
M src/gsm/libosmogsm.map
3 files changed, 15 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/34/7334/1

diff --git a/include/osmocom/gsm/abis_nm.h b/include/osmocom/gsm/abis_nm.h
index dd7ba0d..823b5a4 100644
--- a/include/osmocom/gsm/abis_nm.h
+++ b/include/osmocom/gsm/abis_nm.h
@@ -41,16 +41,14 @@
 extern const struct tlv_definition abis_nm_osmo_att_tlvdef;
 extern const struct tlv_definition abis_nm_att_tlvdef_ipa;
 
+const char *abis_nm_dump_foh(const struct abis_om_fom_hdr *foh);
+
 /*! write a human-readable OML header to the debug log
  *  \param[in] ss Logging sub-system
  *  \param[in] foh A-bis OML FOM header
  */
 #define abis_nm_debugp_foh(ss, foh)					    \
-	DEBUGP(ss, "OC=%s(%02x) INST=(%02x,%02x,%02x) ",		    \
-		get_value_string(abis_nm_obj_class_names, (foh)->obj_class),  \
-		(foh)->obj_class, (foh)->obj_inst.bts_nr, (foh)->obj_inst.trx_nr, \
-		(foh)->obj_inst.ts_nr)
-
+	DEBUGP(ss, "%s ", abis_nm_dump_foh(foh))
 
 int abis_nm_chcomb4pchan(enum gsm_phys_chan_config pchan);
 enum gsm_phys_chan_config abis_nm_pchan4chcomb(uint8_t chcomb);
diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c
index 8a3886d..49d05ba 100644
--- a/src/gsm/abis_nm.c
+++ b/src/gsm/abis_nm.c
@@ -928,15 +928,22 @@
 	return GSM_PCHAN_NONE;
 }
 
+const char *abis_nm_dump_foh(const struct abis_om_fom_hdr *foh)
+{
+	static char foh_buf[128];
+	snprintf(foh_buf, sizeof(foh_buf), "OC=%s(%02x) INST=(%02x,%02x,%02x)",
+		get_value_string(abis_nm_obj_class_names, foh->obj_class),
+		foh->obj_class, foh->obj_inst.bts_nr, foh->obj_inst.trx_nr,
+		foh->obj_inst.ts_nr);
+	return foh_buf;
+}
+
 /* this is just for compatibility reasons, it is now a macro */
 #undef abis_nm_debugp_foh
 OSMO_DEPRECATED("Use abis_nm_debugp_foh macro instead")
 void abis_nm_debugp_foh(int ss, struct abis_om_fom_hdr *foh)
 {
-	DEBUGP(ss, "OC=%s(%02x) INST=(%02x,%02x,%02x) ",
-		get_value_string(abis_nm_obj_class_names, foh->obj_class),
-		foh->obj_class, foh->obj_inst.bts_nr, foh->obj_inst.trx_nr,
-		foh->obj_inst.ts_nr);
+	DEBUGP(ss, "%s ", abis_nm_dump_foh(foh));
 }
 
 /*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 36a7712..fd07704 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -8,6 +8,7 @@
 abis_nm_fail_evt_vrep;
 abis_nm_chcomb4pchan;
 abis_nm_debugp_foh;
+abis_nm_dump_foh;
 abis_nm_event_type_name;
 abis_nm_nack_cause_name;
 abis_nm_nack_name;

-- 
To view, visit https://gerrit.osmocom.org/7334
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b2c2afec28882b817d104d5b062651ade7aadd8
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list