Deleted Added
full compact
usbdump.c (216138) usbdump.c (218010)
1/*-
2 * Copyright (c) 2010 Weongyo Jeong <weongyo@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 *
1/*-
2 * Copyright (c) 2010 Weongyo Jeong <weongyo@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 *
29 * $FreeBSD: head/usr.sbin/usbdump/usbdump.c 216138 2010-12-03 00:44:07Z weongyo $
29 * $FreeBSD: head/usr.sbin/usbdump/usbdump.c 218010 2011-01-28 08:00:57Z hselasky $
30 */
31
32#include <sys/param.h>
33#include <sys/endian.h>
34#include <sys/ioctl.h>
35#include <sys/socket.h>
36#include <sys/stat.h>
37#include <sys/utsname.h>

--- 29 unchanged lines hidden (view full) ---

67 u_char major;
68 u_char minor;
69 u_char reserved[26];
70} __packed;
71
72static int doexit = 0;
73static int pkt_captured = 0;
74static int verbose = 0;
30 */
31
32#include <sys/param.h>
33#include <sys/endian.h>
34#include <sys/ioctl.h>
35#include <sys/socket.h>
36#include <sys/stat.h>
37#include <sys/utsname.h>

--- 29 unchanged lines hidden (view full) ---

67 u_char major;
68 u_char minor;
69 u_char reserved[26];
70} __packed;
71
72static int doexit = 0;
73static int pkt_captured = 0;
74static int verbose = 0;
75static const char *i_arg = "usbus0";;
75static const char *i_arg = "usbus0";
76static const char *r_arg = NULL;
77static const char *w_arg = NULL;
78static const char *errstr_table[USB_ERR_MAX] = {
79 [USB_ERR_NORMAL_COMPLETION] = "NORMAL_COMPLETION",
80 [USB_ERR_PENDING_REQUESTS] = "PENDING_REQUESTS",
81 [USB_ERR_NOT_STARTED] = "NOT_STARTED",
82 [USB_ERR_INVAL] = "INVAL",
83 [USB_ERR_NOMEM] = "NOMEM",

--- 96 unchanged lines hidden (view full) ---

180
181/*
182 * Display a region in traditional hexdump format.
183 */
184static void
185hexdump(const char *region, size_t len)
186{
187 const char *line;
76static const char *r_arg = NULL;
77static const char *w_arg = NULL;
78static const char *errstr_table[USB_ERR_MAX] = {
79 [USB_ERR_NORMAL_COMPLETION] = "NORMAL_COMPLETION",
80 [USB_ERR_PENDING_REQUESTS] = "PENDING_REQUESTS",
81 [USB_ERR_NOT_STARTED] = "NOT_STARTED",
82 [USB_ERR_INVAL] = "INVAL",
83 [USB_ERR_NOMEM] = "NOMEM",

--- 96 unchanged lines hidden (view full) ---

180
181/*
182 * Display a region in traditional hexdump format.
183 */
184static void
185hexdump(const char *region, size_t len)
186{
187 const char *line;
188 int x, c;
189 char lbuf[80];
190#define EMIT(fmt, args...) do { \
191 sprintf(lbuf, fmt , ## args); \
192 printf("%s", lbuf); \
188 int x;
189 int c;
190#define EMIT(fmt, ...) do { \
191 printf(fmt,## __VA_ARGS__); \
193} while (0)
194
195 for (line = region; line < (region + len); line += 16) {
196 EMIT(" %04lx ", (long) (line - region));
197 for (x = 0; x < 16; x++) {
198 if ((line + x) < (region + len))
199 EMIT("%02x ", *(const u_int8_t *)(line + x));
200 else

--- 344 unchanged lines hidden ---
192} while (0)
193
194 for (line = region; line < (region + len); line += 16) {
195 EMIT(" %04lx ", (long) (line - region));
196 for (x = 0; x < 16; x++) {
197 if ((line + x) < (region + len))
198 EMIT("%02x ", *(const u_int8_t *)(line + x));
199 else

--- 344 unchanged lines hidden ---