summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vppinfra/format.h3
-rw-r--r--src/vppinfra/std-formats.c66
2 files changed, 69 insertions, 0 deletions
diff --git a/src/vppinfra/format.h b/src/vppinfra/format.h
index a359328005f..935b57f2c4b 100644
--- a/src/vppinfra/format.h
+++ b/src/vppinfra/format.h
@@ -321,6 +321,9 @@ u8 *format_c_identifier (u8 * s, va_list * va);
/* Format hexdump with both hex and printable chars - compatible with text2pcap */
u8 *format_hexdump (u8 * s, va_list * va);
+u8 *format_hexdump_u16 (u8 *s, va_list *va);
+u8 *format_hexdump_u32 (u8 *s, va_list *va);
+u8 *format_hexdump_u64 (u8 *s, va_list *va);
/* Format bitmap of array of uword numbers */
u8 *format_uword_bitmap (u8 *s, va_list *va);
diff --git a/src/vppinfra/std-formats.c b/src/vppinfra/std-formats.c
index 4605ed5d75c..7a51a531d31 100644
--- a/src/vppinfra/std-formats.c
+++ b/src/vppinfra/std-formats.c
@@ -456,6 +456,72 @@ format_hexdump (u8 * s, va_list * args)
}
__clib_export u8 *
+format_hexdump_u16 (u8 *s, va_list *args)
+{
+ u16 *data = va_arg (*args, u16 *);
+ u32 len = va_arg (*args, u32);
+ u32 indent = format_get_indent (s);
+
+ if (!len)
+ return s;
+
+ for (int i = 0; i < len; i++)
+ {
+ if (i % 8 == 0)
+ {
+ s = format (s, "%s%U%05x: ", i ? "\n" : "", format_white_space,
+ i ? indent : 0, i * 2);
+ }
+ s = format (s, " %04lx", data[i]);
+ }
+ return s;
+}
+
+__clib_export u8 *
+format_hexdump_u32 (u8 *s, va_list *args)
+{
+ u32 *data = va_arg (*args, u32 *);
+ u32 len = va_arg (*args, u32);
+ u32 indent = format_get_indent (s);
+
+ if (!len)
+ return s;
+
+ for (int i = 0; i < len; i++)
+ {
+ if (i % 4 == 0)
+ {
+ s = format (s, "%s%U%05x: ", i ? "\n" : "", format_white_space,
+ i ? indent : 0, i * 4);
+ }
+ s = format (s, " %08lx", data[i]);
+ }
+ return s;
+}
+
+__clib_export u8 *
+format_hexdump_u64 (u8 *s, va_list *args)
+{
+ u64 *data = va_arg (*args, u64 *);
+ u32 len = va_arg (*args, u32);
+ u32 indent = format_get_indent (s);
+
+ if (!len)
+ return s;
+
+ for (int i = 0; i < len; i++)
+ {
+ if (i % 2 == 0)
+ {
+ s = format (s, "%s%U%05x: ", i ? "\n" : "", format_white_space,
+ i ? indent : 0, i * 8);
+ }
+ s = format (s, " %016lx", data[i]);
+ }
+ return s;
+}
+
+__clib_export u8 *
format_uword_bitmap (u8 *s, va_list *args)
{
uword *bitmap = va_arg (*args, uword *);