MCPcopy Create free account
hub / github.com/F-Stack/f-stack / _NgDebugBytes

Function _NgDebugBytes

tools/libnetgraph/debug.c:322–358  ·  view source on GitHub ↗

* Dump bytes in hex */

Source from the content-addressed store, hash-verified

320 * Dump bytes in hex
321 */
322void
323_NgDebugBytes(const u_char *ptr, int len)
324{
325 char buf[100];
326 int k, count;
327
328#define BYPERLINE 16
329
330 for (count = 0; count < len; ptr += BYPERLINE, count += BYPERLINE) {
331
332 /* Do hex */
333 snprintf(buf, sizeof(buf), "%04x: ", count);
334 for (k = 0; k < BYPERLINE; k++, count++)
335 if (count < len)
336 snprintf(buf + strlen(buf),
337 sizeof(buf) - strlen(buf), "%02x ", ptr[k]);
338 else
339 snprintf(buf + strlen(buf),
340 sizeof(buf) - strlen(buf), " ");
341 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " ");
342 count -= BYPERLINE;
343
344 /* Do ASCII */
345 for (k = 0; k < BYPERLINE; k++, count++)
346 if (count < len)
347 snprintf(buf + strlen(buf),
348 sizeof(buf) - strlen(buf),
349 "%c", isprint(ptr[k]) ? ptr[k] : '.');
350 else
351 snprintf(buf + strlen(buf),
352 sizeof(buf) - strlen(buf), " ");
353 count -= BYPERLINE;
354
355 /* Print it */
356 NGLOGX("%s", buf);
357 }
358}
359

Callers 3

NgRecvDataFunction · 0.85
NgSendDataFunction · 0.85
_NgDebugMsgFunction · 0.85

Calls 2

snprintfFunction · 0.85
isprintFunction · 0.85

Tested by

no test coverage detected