<p>Neels Hofmeyr has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12658">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add osmo_hexdump_b(), osmo_hexdump_nospc_b(), osmo_hexdump_buf()<br><br>Add osmo_hexdump_b() and osmo_hexdump_nospc_b() to use a second static buffer,<br>allowing more than one hexdump per printf()-like call.<br><br>Add osmo_hexdump_buf() as an all-purpose hexdump function, which all other<br>osmo_hexdump_*() implementations now call. It absorbs the static<br>_osmo_hexdump(). Add tests for osmo_hexdump_buf().<br><br>Rationale: recently during patch review, a situation came up where two hexdumps<br>in a single printf would have been useful. Now I've faced a similar situation<br>again, in ongoing development. So I decided it is time to provide this API.<br><br>Naming: before, I named functions that use a secondary string buffer with a '2'<br>suffix, like osmo_plmn_name() and osmo_plmn_name2(). This time, I decided to<br>use a '_b' suffix, osmo_hexdump_b(), instead. The reason is, by now I think<br>that '2' is a bad choice for secondary-buffer functions: the '2' suffix is<br>already used for introducing a newer API version of function signatures. If we,<br>for example, introduce an osmo_hexdump() that has no final delimiter after the<br>last byte, that would qualify for osmo_hexdump2(); and that would confuse with<br>the implementation simply using a secondary buffer. Sometimes during code<br>review, I assume that the existence of a foo2() function means the patch<br>submitter should use foo2() instead of foo(), and am annoyed by my previous<br>choice of overloading the '2' suffix with a secondary meaning besides "this is<br>newer API".<br><br>Change-Id: I590595567b218b24e53c9eb1fd8736c0324d371d<br>---<br>M include/osmocom/core/utils.h<br>M src/utils.c<br>M tests/utils/utils_test.c<br>M tests/utils/utils_test.ok<br>4 files changed, 186 insertions(+), 11 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/58/12658/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h</span><br><span>index 987080e..ffe6cdd 100644</span><br><span>--- a/include/osmocom/core/utils.h</span><br><span>+++ b/include/osmocom/core/utils.h</span><br><span>@@ -55,7 +55,12 @@</span><br><span> </span><br><span> char *osmo_ubit_dump(const uint8_t *bits, unsigned int len);</span><br><span> char *osmo_hexdump(const unsigned char *buf, int len);</span><br><span style="color: hsl(120, 100%, 40%);">+char *osmo_hexdump_b(const unsigned char *buf, int len);</span><br><span> char *osmo_hexdump_nospc(const unsigned char *buf, int len);</span><br><span style="color: hsl(120, 100%, 40%);">+char *osmo_hexdump_nospc_b(const unsigned char *buf, int len);</span><br><span style="color: hsl(120, 100%, 40%);">+char *osmo_hexdump_buf(char *out_buf, size_t out_buf_size, const unsigned char *buf, int len, const char *delim,</span><br><span style="color: hsl(120, 100%, 40%);">+                   bool delim_after_last);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len) __attribute__((__deprecated__));</span><br><span> </span><br><span> #define osmo_static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1] __attribute__((__unused__));</span><br><span>diff --git a/src/utils.c b/src/utils.c</span><br><span>index d1da4fa..06c2f8a 100644</span><br><span>--- a/src/utils.c</span><br><span>+++ b/src/utils.c</span><br><span>@@ -217,32 +217,58 @@</span><br><span> }</span><br><span> </span><br><span> static char hexd_buff[4096];</span><br><span style="color: hsl(120, 100%, 40%);">+static char hexd_buff2[4096];</span><br><span> static const char hex_chars[] = "0123456789abcdef";</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static char *_osmo_hexdump(const unsigned char *buf, int len, char *delim)</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Convert binary sequence to hexadecimal ASCII string.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[out] out_buf  Output buffer to write the resulting string to.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] out_buf_size  sizeof(out_buf).</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] buf  Input buffer, pointer to sequence of bytes.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] len  Length of input buf in number of bytes.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] delim  String to separate each byte; NULL or "" for no delim.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] delim_after_last  If true, end the string in delim (true: "1a:ef:d9:", false: "1a:ef:d9");</span><br><span style="color: hsl(120, 100%, 40%);">+ *                               if out_buf has insufficient space, the string will always end in a delim.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns out_buf, containing a zero-terminated string, or NULL if out_buf == NULL or out_buf_size < 1.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This function will print a sequence of bytes as hexadecimal numbers, adding one delim between each byte (e.g. for</span><br><span style="color: hsl(120, 100%, 40%);">+ * delim passed as ":", return a string like "1a:ef:d9").</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * The delim_after_last argument exists to be able to exactly show the original osmo_hexdump() behavior, which always</span><br><span style="color: hsl(120, 100%, 40%);">+ * ends the string with a delimiter.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+char *osmo_hexdump_buf(char *out_buf, size_t out_buf_size, const unsigned char *buf, int len, const char *delim,</span><br><span style="color: hsl(120, 100%, 40%);">+                 bool delim_after_last)</span><br><span> {</span><br><span>   int i;</span><br><span style="color: hsl(0, 100%, 40%);">-  char *cur = hexd_buff;</span><br><span style="color: hsl(120, 100%, 40%);">+        char *cur = out_buf;</span><br><span style="color: hsl(120, 100%, 40%);">+  size_t delim_len;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   hexd_buff[0] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!out_buf || !out_buf_size)</span><br><span style="color: hsl(120, 100%, 40%);">+                return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        delim = delim ? : "";</span><br><span style="color: hsl(120, 100%, 40%);">+       delim_len = strlen(delim);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>         for (i = 0; i < len; i++) {</span><br><span>               const char *delimp = delim;</span><br><span style="color: hsl(0, 100%, 40%);">-             int len_remain = sizeof(hexd_buff) - (cur - hexd_buff);</span><br><span style="color: hsl(0, 100%, 40%);">-         if (len_remain < 3)</span><br><span style="color: hsl(120, 100%, 40%);">+                int len_remain = out_buf_size - (cur - out_buf) - 1;</span><br><span style="color: hsl(120, 100%, 40%);">+          if (len_remain < (2 + delim_len)</span><br><span style="color: hsl(120, 100%, 40%);">+               && !(!delim_after_last && i == (len - 1) && len_remain >= 2))</span><br><span>                         break;</span><br><span> </span><br><span>           *cur++ = hex_chars[buf[i] >> 4];</span><br><span>               *cur++ = hex_chars[buf[i] & 0xf];</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+             if (i == (len - 1) && !delim_after_last)</span><br><span style="color: hsl(120, 100%, 40%);">+                      break;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>             while (len_remain > 1 && *delimp) {</span><br><span>                       *cur++ = *delimp++;</span><br><span>                  len_remain--;</span><br><span>                }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-               *cur = 0;</span><br><span>    }</span><br><span style="color: hsl(0, 100%, 40%);">-       hexd_buff[sizeof(hexd_buff)-1] = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-     return hexd_buff;</span><br><span style="color: hsl(120, 100%, 40%);">+     *cur = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+  return out_buf;</span><br><span> }</span><br><span> </span><br><span> /*! Convert a sequence of unpacked bits to ASCII string</span><br><span>@@ -292,7 +318,18 @@</span><br><span>  */</span><br><span> char *osmo_hexdump(const unsigned char *buf, int len)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- return _osmo_hexdump(buf, len, " ");</span><br><span style="color: hsl(120, 100%, 40%);">+        return osmo_hexdump_buf(hexd_buff, sizeof(hexd_buff), buf, len, " ", true);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Same as osmo_hexdump() but use a separate static buffer.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Allows passing a second osmo_hexdump() as print format argument.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] buf pointer to sequence of bytes.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] len length of buf in number of bytes.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns pointer to zero-terminated string.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+char *osmo_hexdump_b(const unsigned char *buf, int len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       return osmo_hexdump_buf(hexd_buff2, sizeof(hexd_buff2), buf, len, " ", true);</span><br><span> }</span><br><span> </span><br><span> /*! Convert binary sequence to hexadecimal ASCII string</span><br><span>@@ -308,7 +345,18 @@</span><br><span>  */</span><br><span> char *osmo_hexdump_nospc(const unsigned char *buf, int len)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-   return _osmo_hexdump(buf, len, "");</span><br><span style="color: hsl(120, 100%, 40%);">+ return osmo_hexdump_buf(hexd_buff, sizeof(hexd_buff), buf, len, "", true);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Same as osmo_hexdump_nospc() but use a separate static buffer.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Allows passing a second osmo_hexdump() as print format argument.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] buf pointer to sequence of bytes</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] len length of buf in number of bytes</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns pointer to zero-terminated string</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+char *osmo_hexdump_nospc_b(const unsigned char *buf, int len)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       return osmo_hexdump_buf(hexd_buff2, sizeof(hexd_buff2), buf, len, "", true);</span><br><span> }</span><br><span> </span><br><span> /* Compat with previous typo to preserve abi */</span><br><span>diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c</span><br><span>index a773b3f..822861f 100644</span><br><span>--- a/tests/utils/utils_test.c</span><br><span>+++ b/tests/utils/utils_test.c</span><br><span>@@ -37,6 +37,7 @@</span><br><span> static void hexdump_test(void)</span><br><span> {</span><br><span>   uint8_t data[4098];</span><br><span style="color: hsl(120, 100%, 40%);">+   char buf[256];</span><br><span>       int i;</span><br><span> </span><br><span>   for (i = 0; i < ARRAY_SIZE(data); ++i)</span><br><span>@@ -44,10 +45,34 @@</span><br><span> </span><br><span>  printf("Plain dump\n");</span><br><span>    printf("%s\n", osmo_hexdump(data, 4));</span><br><span style="color: hsl(120, 100%, 40%);">+      printf("%s\n", osmo_hexdump_nospc(data, 4));</span><br><span> </span><br><span>   printf("Corner case\n");</span><br><span>   printf("%s\n", osmo_hexdump(data, ARRAY_SIZE(data)));</span><br><span>      printf("%s\n", osmo_hexdump_nospc(data, ARRAY_SIZE(data)));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define _HEXDUMP_BUF_TEST(SIZE, DELIM, DELIM_AFTER) \</span><br><span style="color: hsl(120, 100%, 40%);">+        buf[0] = '!'; \</span><br><span style="color: hsl(120, 100%, 40%);">+       buf[1] = '\0'; \</span><br><span style="color: hsl(120, 100%, 40%);">+      printf("osmo_hexdump_buf(buf, " #SIZE ", data, 4, %s, " #DELIM_AFTER ")\n = \"%s\"\n", \</span><br><span style="color: hsl(120, 100%, 40%);">+             DELIM ? #DELIM : "NULL", \</span><br><span style="color: hsl(120, 100%, 40%);">+          osmo_hexdump_buf(buf, SIZE, data, 4, DELIM, DELIM_AFTER))</span><br><span style="color: hsl(120, 100%, 40%);">+#define HEXDUMP_BUF_TEST(DELIM) \</span><br><span style="color: hsl(120, 100%, 40%);">+   _HEXDUMP_BUF_TEST(sizeof(buf), DELIM, false); \</span><br><span style="color: hsl(120, 100%, 40%);">+       _HEXDUMP_BUF_TEST(sizeof(buf), DELIM, true); \</span><br><span style="color: hsl(120, 100%, 40%);">+        _HEXDUMP_BUF_TEST(6, DELIM, false); \</span><br><span style="color: hsl(120, 100%, 40%);">+ _HEXDUMP_BUF_TEST(7, DELIM, false); \</span><br><span style="color: hsl(120, 100%, 40%);">+ _HEXDUMP_BUF_TEST(8, DELIM, false); \</span><br><span style="color: hsl(120, 100%, 40%);">+ _HEXDUMP_BUF_TEST(6, DELIM, true); \</span><br><span style="color: hsl(120, 100%, 40%);">+  _HEXDUMP_BUF_TEST(7, DELIM, true); \</span><br><span style="color: hsl(120, 100%, 40%);">+  _HEXDUMP_BUF_TEST(8, DELIM, true)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   HEXDUMP_BUF_TEST("[delim]");</span><br><span style="color: hsl(120, 100%, 40%);">+        HEXDUMP_BUF_TEST(" ");</span><br><span style="color: hsl(120, 100%, 40%);">+      HEXDUMP_BUF_TEST(":");</span><br><span style="color: hsl(120, 100%, 40%);">+      HEXDUMP_BUF_TEST("::");</span><br><span style="color: hsl(120, 100%, 40%);">+     HEXDUMP_BUF_TEST("");</span><br><span style="color: hsl(120, 100%, 40%);">+       HEXDUMP_BUF_TEST(NULL);</span><br><span> }</span><br><span> </span><br><span> static void hexparse_test(void)</span><br><span>diff --git a/tests/utils/utils_test.ok b/tests/utils/utils_test.ok</span><br><span>index 65e32ed..8d7ced8 100644</span><br><span>--- a/tests/utils/utils_test.ok</span><br><span>+++ b/tests/utils/utils_test.ok</span><br><span>@@ -1,8 +1,105 @@</span><br><span> Plain dump</span><br><span> 00 01 02 03 </span><br><span style="color: hsl(120, 100%, 40%);">+00010203</span><br><span> Corner case</span><br><span> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 </span><br><span> 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, "[delim]", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00[delim]01[delim]02[delim]03"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, "[delim]", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00[delim]01[delim]02[delim]03[delim]"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, "[delim]", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = ""</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, "[delim]", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = ""</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, "[delim]", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = ""</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, "[delim]", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = ""</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, "[delim]", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = ""</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, "[delim]", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = ""</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, " ", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00 01 02 03"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, " ", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00 01 02 03 "</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, " ", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00 "</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, " ", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00 01 "</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, " ", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00 01 "</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, " ", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00 "</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, " ", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00 01 "</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, " ", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00 01 "</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, ":", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00:01:02:03"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, ":", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00:01:02:03:"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, ":", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00:"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, ":", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00:01:"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, ":", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00:01:"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, ":", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00:"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, ":", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00:01:"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, ":", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00:01:"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, "::", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00::01::02::03"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, "::", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00::01::02::03::"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, "::", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00::"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, "::", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00::"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, "::", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00::"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, "::", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00::"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, "::", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00::"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, "::", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00::"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, "", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00010203"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, "", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00010203"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, "", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "0001"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, "", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "000102"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, "", false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "000102"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, "", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "0001"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, "", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "000102"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, "", true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "000102"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, NULL, false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00010203"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, sizeof(buf), data, 4, NULL, true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "00010203"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, NULL, false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "0001"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, NULL, false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "000102"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, NULL, false)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "000102"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 6, data, 4, NULL, true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "0001"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 7, data, 4, NULL, true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "000102"</span><br><span style="color: hsl(120, 100%, 40%);">+osmo_hexdump_buf(buf, 8, data, 4, NULL, true)</span><br><span style="color: hsl(120, 100%, 40%);">+ = "000102"</span><br><span> </span><br><span> Hexparse 0..255 in lower case</span><br><span> rc = 256</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12658">change 12658</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12658"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I590595567b218b24e53c9eb1fd8736c0324d371d </div>
<div style="display:none"> Gerrit-Change-Number: 12658 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>