From 3860a77e9ff1d945259301045db339667c2c2c6d Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 17 Jun 2019 23:20:27 +0200 Subject: vppinfra: add format_hex_bytes_no_wrap Type: feature Change-Id: I53e1f05b2b048925fca3b2f6b0499ff9c3e6ee12 Signed-off-by: Damjan Marion --- src/vppinfra/format.h | 1 + src/vppinfra/std-formats.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'src/vppinfra') diff --git a/src/vppinfra/format.h b/src/vppinfra/format.h index 94344474067..c4becff3a67 100644 --- a/src/vppinfra/format.h +++ b/src/vppinfra/format.h @@ -94,6 +94,7 @@ _(format_vec32); _(format_vec_uword); _(format_ascii_bytes); _(format_hex_bytes); +_(format_hex_bytes_no_wrap); _(format_white_space); _(format_f64); _(format_time_interval); diff --git a/src/vppinfra/std-formats.c b/src/vppinfra/std-formats.c index da3c54cc07e..b771b947e27 100644 --- a/src/vppinfra/std-formats.c +++ b/src/vppinfra/std-formats.c @@ -108,6 +108,22 @@ format_hex_bytes (u8 * s, va_list * va) return s; } +u8 * +format_hex_bytes_no_wrap (u8 * s, va_list * va) +{ + u8 *bytes = va_arg (*va, u8 *); + int n_bytes = va_arg (*va, int); + uword i; + + if (n_bytes == 0) + return s; + + for (i = 0; i < n_bytes; i++) + s = format (s, "%02x", bytes[i]); + + return s; +} + /* Add variable number of spaces. */ u8 * format_white_space (u8 * s, va_list * va) -- cgit 1.2.3-korg