diff options
author | Neels Janosch Hofmeyr <nhofmeyr@sysmocom.de> | 2022-12-01 03:59:12 +0100 |
---|---|---|
committer | Neels Janosch Hofmeyr <nhofmeyr@sysmocom.de> | 2022-12-08 04:23:09 +0100 |
commit | 43dd5ddf97023552d0f3cd695d73603645414320 (patch) | |
tree | c15eed24b9c244a249c624a646edb462f844441e /src | |
parent | 4f6c95cc770fb1f6098cedac90e0233bc5a493e9 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/libosmo-pfcp/pfcp_ies_custom.c | 8 |
1 files changed, 5 insertions, 3 deletions
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; } |