1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2018 Nexenta Systems, Inc. All rights reserved. 14 */ 15 16 /* 17 * Test & debug program for smb_msgbuf.c and smb_mbuf_marshaling.c 18 */ 19 20 #include <sys/types.h> 21 #include <sys/debug.h> 22 23 #include <stdio.h> 24 #include <stdlib.h> 25 #include <string.h> 26 #include <strings.h> 27 #include <unistd.h> 28 29 #include "test_defs.h" 30 31 32 int 33 main(int argc, char *argv[]) 34 { 35 36 test_conv(); 37 test_mbmarshal(); 38 test_msgbuf(); 39 40 return (0); 41 } 42 43 void 44 hexdump(const uchar_t *buf, int len) 45 { 46 int idx; 47 char ascii[24]; 48 char *pa = ascii; 49 50 memset(ascii, '\0', sizeof (ascii)); 51 52 idx = 0; 53 while (len--) { 54 if ((idx & 15) == 0) { 55 printf("%04X: ", idx); 56 pa = ascii; 57 } 58 if (*buf > ' ' && *buf <= '~') 59 *pa++ = *buf; 60 else 61 *pa++ = '.'; 62 printf("%02x ", *buf++); 63 64 idx++; 65 if ((idx & 3) == 0) { 66 *pa++ = ' '; 67 putchar(' '); 68 } 69 if ((idx & 15) == 0) { 70 *pa = '\0'; 71 printf("%s\n", ascii); 72 } 73 } 74 75 if ((idx & 15) != 0) { 76 *pa = '\0'; 77 /* column align the last ascii row */ 78 while ((idx & 15) != 0) { 79 if ((idx & 3) == 0) 80 putchar(' '); 81 printf(" "); 82 idx++; 83 } 84 printf("%s\n", ascii); 85 } 86 }