xref: /freebsd/usr.sbin/usbdump/usbdump.8 (revision f50d2fced24f4dbffc1cc414da48ea7ef7b84d1e)
1e64ac239SWeongyo Jeong.\"
2e64ac239SWeongyo Jeong.\" Copyright (c) 2010 Weongyo Jeong.
3e64ac239SWeongyo Jeong.\" All rights reserved.
4e64ac239SWeongyo Jeong.\"
5e64ac239SWeongyo Jeong.\" Redistribution and use in source and binary forms, with or without
6e64ac239SWeongyo Jeong.\" modification, are permitted provided that the following conditions
7e64ac239SWeongyo Jeong.\" are met:
8e64ac239SWeongyo Jeong.\" 1. Redistributions of source code must retain the above copyright
9e64ac239SWeongyo Jeong.\"    notice, this list of conditions and the following disclaimer.
10e64ac239SWeongyo Jeong.\" 2. Redistributions in binary form must reproduce the above copyright
11e64ac239SWeongyo Jeong.\"    notice, this list of conditions and the following disclaimer in the
12e64ac239SWeongyo Jeong.\"    documentation and/or other materials provided with the distribution.
13e64ac239SWeongyo Jeong.\"
14e64ac239SWeongyo Jeong.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15e64ac239SWeongyo Jeong.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16e64ac239SWeongyo Jeong.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17e64ac239SWeongyo Jeong.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18e64ac239SWeongyo Jeong.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19e64ac239SWeongyo Jeong.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20e64ac239SWeongyo Jeong.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21e64ac239SWeongyo Jeong.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22e64ac239SWeongyo Jeong.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23e64ac239SWeongyo Jeong.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24e64ac239SWeongyo Jeong.\" SUCH DAMAGE.
25e64ac239SWeongyo Jeong.\"
26c904e20cSHans Petter Selasky.Dd May 14, 2021
27a6d11f71SRuslan Ermilov.Dt USBDUMP 8
28e64ac239SWeongyo Jeong.Os
29e64ac239SWeongyo Jeong.Sh NAME
30e64ac239SWeongyo Jeong.Nm usbdump
31e64ac239SWeongyo Jeong.Nd "dump traffic on USB host controller"
32e64ac239SWeongyo Jeong.Sh SYNOPSIS
33e64ac239SWeongyo Jeong.Nm
34c904e20cSHans Petter Selasky.Op Fl d Ar [ugen]B
35c904e20cSHans Petter Selasky.Op Fl d Ar [ugen]B.D
36c904e20cSHans Petter Selasky.Op Fl d Ar [ugen]B.D.E
37e64ac239SWeongyo Jeong.Op Fl i Ar ifname
38e64ac239SWeongyo Jeong.Op Fl r Ar file
39e64ac239SWeongyo Jeong.Op Fl s Ar snaplen
40*f50d2fceSPoul-Henning Kamp.Op Fl u
41e64ac239SWeongyo Jeong.Op Fl v
42e64ac239SWeongyo Jeong.Op Fl w Ar file
4379fcfd2eSHans Petter Selasky.Op Fl f Ar filter
44fa001545SHans Petter Selasky.Op Fl b Ar file
454573cfdbSHans Petter Selasky.Op Fl h
46e64ac239SWeongyo Jeong.Sh DESCRIPTION
47e64ac239SWeongyo JeongThe
48e64ac239SWeongyo Jeong.Nm
4958ea8701SWeongyo Jeongutility provides a way to dump USB packets on host controllers.
50e64ac239SWeongyo Jeong.Pp
5158ea8701SWeongyo JeongThe following options are accepted:
52e64ac239SWeongyo Jeong.Bl -tag -width ".Fl f Ar file"
53c904e20cSHans Petter Selasky.It Fl d Ar [ugen]bus
54c904e20cSHans Petter SelaskyShortcut for
55c904e20cSHans Petter Selasky.Fl i
56c904e20cSHans Petter Selaskyoption.
57c904e20cSHans Petter SelaskyThe argument may be prefixed by "ugen".
58c904e20cSHans Petter SelaskyThe option may be specified multiple times, but the bus specified must
59c904e20cSHans Petter Selaskybe the same.
60c904e20cSHans Petter Selasky.It Fl d Ar [ugen]bus.device
61c904e20cSHans Petter SelaskyShortcut for
62c904e20cSHans Petter Selasky.Fl i
63c904e20cSHans Petter Selaskyand
64c904e20cSHans Petter Selasky.Fl f
65c904e20cSHans Petter Selaskyoptions.
66c904e20cSHans Petter SelaskyThe argument may be prefixed by "ugen".
67c904e20cSHans Petter SelaskyThe option may be specified multiple times, but the bus specified must
68c904e20cSHans Petter Selaskybe the same.
69c904e20cSHans Petter Selasky.It Fl d Ar [ugen]bus.device.endpoint
70c904e20cSHans Petter SelaskyShortcut for
71c904e20cSHans Petter Selasky.Fl i
72c904e20cSHans Petter Selaskyand
73c904e20cSHans Petter Selasky.Fl f
74c904e20cSHans Petter Selaskyoptions.
75c904e20cSHans Petter SelaskyThe argument may be prefixed by "ugen".
76c904e20cSHans Petter SelaskyThe option may be specified multiple times, but the bus specified must
77c904e20cSHans Petter Selaskybe the same.
78fa001545SHans Petter Selasky.It Fl b Ar file
79fa001545SHans Petter SelaskyStore data part of the USB trace in binary format to the given
80fa001545SHans Petter Selasky.Ar file .
81fa001545SHans Petter SelaskyThis option also works with the -r and -f options.
82e64ac239SWeongyo Jeong.It Fl i Ar ifname
8358ea8701SWeongyo JeongListen on USB bus interface
8458ea8701SWeongyo Jeong.Ar ifname .
85e64ac239SWeongyo Jeong.It Fl r Ar file
8658ea8701SWeongyo JeongRead the raw packets from
8758ea8701SWeongyo Jeong.Ar file .
88fa001545SHans Petter SelaskyThis option also works with the -f option.
89e64ac239SWeongyo Jeong.It Fl s Ar snaplen
9058ea8701SWeongyo JeongSnapshot
9158ea8701SWeongyo Jeong.Ar snaplen
9258ea8701SWeongyo Jeongbytes from each packet.
93*f50d2fceSPoul-Henning Kamp.It Fl u
94*f50d2fceSPoul-Henning KampUnbuffered output.
95e64ac239SWeongyo Jeong.It Fl v
96e64ac239SWeongyo JeongEnable debugging messages.
9758ea8701SWeongyo JeongWhen defined multiple times the verbosity level increases.
98e64ac239SWeongyo Jeong.It Fl w Ar file
9958ea8701SWeongyo JeongWrite the raw packets to
10058ea8701SWeongyo Jeong.Ar file .
101fa001545SHans Petter SelaskyThis option also works with the -s and -v options.
10279fcfd2eSHans Petter Selasky.It Fl f Ar filter
10379fcfd2eSHans Petter SelaskyThe filter argument consists of either one or two numbers separated by a dot.
10479fcfd2eSHans Petter SelaskyThe first indicates the device unit number which should be traced.
10579fcfd2eSHans Petter SelaskyThe second number which is optional indicates the endpoint which should be traced.
10679fcfd2eSHans Petter SelaskyTo get all traffic for the control endpoint, two filters should be
10779fcfd2eSHans Petter Selaskycreated, one for endpoint 0 and one for endpoint 128.
10879fcfd2eSHans Petter SelaskyIf 128 is added to the endpoint number that means IN direction, else OUT direction is implied.
10979fcfd2eSHans Petter SelaskyA device unit or endpoint value of -1 means ignore this field.
11079fcfd2eSHans Petter SelaskyIf no filters are specified, all packets are passed through using the default -1,-1 filter.
11179fcfd2eSHans Petter SelaskyThis option can be specified multiple times.
1124573cfdbSHans Petter Selasky.It Fl h
1134573cfdbSHans Petter SelaskyThis option displays a summary of the command line options.
114e64ac239SWeongyo Jeong.El
115e64ac239SWeongyo Jeong.Sh EXAMPLES
1166b436e62SBenedict ReuschlingCapture the USB raw packets on usbus2:
117e64ac239SWeongyo Jeong.Pp
118e64ac239SWeongyo Jeong.Dl "usbdump -i usbus2 -s 256 -v"
119e64ac239SWeongyo Jeong.Pp
1206b436e62SBenedict ReuschlingDump the USB raw packets of usbus2 into the file without packet
121e64ac239SWeongyo Jeongsize limit:
122e64ac239SWeongyo Jeong.Pp
123e64ac239SWeongyo Jeong.Dl "usbdump -i usbus2 -s 0 -w /tmp/dump_pkts"
124e64ac239SWeongyo Jeong.Pp
12579fcfd2eSHans Petter SelaskyDump the USB raw packets of usbus2, but only the control endpoint traffic
12679fcfd2eSHans Petter Selaskyof device unit number 3:
12779fcfd2eSHans Petter Selasky.Pp
12879fcfd2eSHans Petter Selasky.Dl "usbdump -i usbus2 -s 0 -f 3.0 -f 3.128 -w /tmp/dump_pkts"
12979fcfd2eSHans Petter Selasky.Pp
1306b436e62SBenedict ReuschlingRead and display the USB raw packets from previous file:
131e64ac239SWeongyo Jeong.Pp
132e64ac239SWeongyo Jeong.Dl "usbdump -r /tmp/dump_pkts -v"
13358ea8701SWeongyo Jeong.Sh OUTPUT FORMAT
13458ea8701SWeongyo JeongThe output format of
13558ea8701SWeongyo Jeong.Nm
13658ea8701SWeongyo Jeongis as follows:
13758ea8701SWeongyo Jeong.Pp
13858ea8701SWeongyo Jeong.Dl "<time> <bus>.<addr> <ep> <xfertype> <S/D> (<frames>/<length>) <...>"
13958ea8701SWeongyo Jeong.Pp
14058ea8701SWeongyo JeongThe meaning of the output format elements is as follows:
14158ea8701SWeongyo Jeong.Bl -tag -width "<xfertype>"
14258ea8701SWeongyo Jeong.It <time>
14358ea8701SWeongyo JeongA timestamp preceding all output lines.
14458ea8701SWeongyo JeongThe timestamp has the format "hh:mm:ss.frac" and is as accurate as
14558ea8701SWeongyo Jeongthe kernel's clock.
14658ea8701SWeongyo Jeong.It <bus>
14758ea8701SWeongyo JeongThe USB host controller's bus unit number.
14858ea8701SWeongyo Jeong.It <addr>
14958ea8701SWeongyo JeongThe unique number of the USB device as allocated by the host controller driver.
15058ea8701SWeongyo Jeong.It <ep>
15158ea8701SWeongyo JeongThe USB endpoint address that indicates whether the address is
15258ea8701SWeongyo Jeong.Dv OUT
15358ea8701SWeongyo Jeongor
15458ea8701SWeongyo Jeong.Dv IN .
15558ea8701SWeongyo Jeong.It <xfertype>
15658ea8701SWeongyo JeongThe USB transfer type.
15758ea8701SWeongyo JeongCan be
15858ea8701SWeongyo Jeong.Dv CTRL ,
15958ea8701SWeongyo Jeong.Dv ISOC ,
16058ea8701SWeongyo Jeong.Dv BULK
16158ea8701SWeongyo Jeongor
16258ea8701SWeongyo Jeong.Dv INTR .
16358ea8701SWeongyo Jeong.It <S/D>
16458ea8701SWeongyo Jeong`S' indicates a USB submit.
16558ea8701SWeongyo Jeong`D' indicates a USB transfer done.
16658ea8701SWeongyo Jeong.It <frames>
16758ea8701SWeongyo JeongNumbers of frames in this packets.
16858ea8701SWeongyo JeongIf this is a USB submit, its value is
16958ea8701SWeongyo Jeong.Li xfer->nframes
17058ea8701SWeongyo Jeongwhich means how many frames are acceptable or registered to transfer.
17158ea8701SWeongyo JeongIf this is a USB done,
17258ea8701SWeongyo Jeong.Li xfer->aframes
17358ea8701SWeongyo Jeongis the actual number of frames.
17458ea8701SWeongyo Jeong.It <length>
17558ea8701SWeongyo JeongTotal packet size.
17658ea8701SWeongyo JeongIf this is a USB submit, its value is
17758ea8701SWeongyo Jeong.Li xfer->sumlen .
17858ea8701SWeongyo JeongIf this is a USB done, its value is
17958ea8701SWeongyo Jeong.Li xfer->actlen .
18058ea8701SWeongyo Jeong.It <...>
18158ea8701SWeongyo JeongOptional field used for printing an error string if the packet is from USB done.
18258ea8701SWeongyo Jeong.El
183e64ac239SWeongyo Jeong.Sh SEE ALSO
184e64ac239SWeongyo Jeong.Xr usbconfig 8
185e64ac239SWeongyo Jeong.Sh AUTHORS
18601c2b8acSBaptiste Daroussin.An Weongyo Jeong Aq Mt weongyo@FreeBSD.org
187