From 43dd5ddf97023552d0f3cd695d73603645414320 Mon Sep 17 00:00:00 2001 From: Neels Janosch Hofmeyr Date: Thu, 1 Dec 2022 03:59:12 +0100 Subject: bitmask to string: shorten Remove braces and spaces from PFCP bits to string conversion. Instead of "( FOO BAR BAZ )", print "FOO+BAR+BAZ". Instead of "( FORW )", print "FORW". Instead of "( )", print "-". The spaces tend to break up readability of strings logged by osmo-upf. In particular, this affects UP and CP capability bits, Apply Action, Outer Header Creation. Change-Id: I38426d6381e96d4a683e46eba1bdd29c73d3f027 --- src/libosmo-pfcp/pfcp_ies_custom.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/libosmo-pfcp/pfcp_ies_custom.c b/src/libosmo-pfcp/pfcp_ies_custom.c index b334241..e2e9f02 100644 --- a/src/libosmo-pfcp/pfcp_ies_custom.c +++ b/src/libosmo-pfcp/pfcp_ies_custom.c @@ -411,13 +411,15 @@ void osmo_pfcp_bits_set(uint8_t *bits, unsigned int bitpos, bool val) int osmo_pfcp_bits_to_str_buf(char *buf, size_t buflen, const uint8_t *bits, const struct value_string *bit_strs) { struct osmo_strbuf sb = { .buf = buf, .len = buflen }; - OSMO_STRBUF_PRINTF(sb, "("); + bool first = true; for (; bit_strs->str; bit_strs++) { if (osmo_pfcp_bits_get(bits, bit_strs->value)) { - OSMO_STRBUF_PRINTF(sb, " %s", bit_strs->str); + OSMO_STRBUF_PRINTF(sb, "%s%s", first ? "" : "+", bit_strs->str); + first = false; } } - OSMO_STRBUF_PRINTF(sb, " )"); + if (first) + OSMO_STRBUF_PRINTF(sb, "-"); return sb.chars_needed; } -- cgit v1.2.3